--- webform.module.orig	2008-06-30 14:15:57.000000000 -0600
+++ webform.module	2008-06-30 14:21:40.000000000 -0600
@@ -1449,6 +1449,16 @@
     return;
   }
 
+  if (!is_array($form_values['submitted'])) {
+    $form_values['submitted'] = array();
+  }
+  foreach ($node->webform['components'] as $cid => $component) {
+    if ($component['type'] == "fieldset" &&
+        count($form_values['submitted'][$component['form_key']]) < 1) {
+      $form_values['submitted'][$component['form_key']] = array();
+    }
+  }
+
   if (is_array($_SESSION[$session_key])) {
     // Merge any submission data stored in $_SESSION for multistep forms.
     $original_values = is_array($form_values['submitted']) ? $form_values['submitted'] : array();
@@ -1639,6 +1649,12 @@
   if (is_array($form_values)) {
     foreach ($form_values as $form_key => $value) {
       $cid = webform_get_cid($node, $form_key, $parent);
+      while ($cid == NULL) {
+        $parent += 1;
+        $cid = webform_get_cid($node, $form_key, $parent);
+      }
+      $parent = 0;
+
       if (is_array($value) && $node->webform['components'][$cid]['type'] == 'fieldset') {
         _webform_client_form_submit_process($node, $form_values[$form_key], $cid);
       }
@@ -1664,6 +1680,11 @@
   if (is_array($fieldset)) {
     foreach ($fieldset as $form_key => $value) {
       $cid = webform_get_cid($node, $form_key, $parent);
+      while ($cid == NULL) {
+        $parent += 1;
+        $cid = webform_get_cid($node, $form_key, $parent);
+      }
+      $parent = 0;
 
       if (is_array($value) && $node->webform['components'][$cid]['type'] == 'fieldset') {
         _webform_client_form_submit_flatten($node, $value, $form, $cid);
@@ -1806,8 +1827,12 @@
       $message .= $indent . $component['name'] .":\n";
     }
     foreach ($value as $k => $v) {
+      $cid = 0;
       foreach ($node->webform['components'] as $local_key => $local_value) {
-        if ($local_value['form_key'] == $k && $local_value['pid'] == $cid) {
+        if ($local_value['form_key'] == $k) {
+          while ($local_value['pid'] != $cid) {
+            $cid += 1;
+          }
           $form_key = $local_key;
           break;
         }
