--- webform/components/grid.inc	2009-01-11 03:51:47.000000000 +0100
+++ webform.new/components/grid.inc	2009-04-28 11:11:51.000000000 +0200
@@ -111,11 +111,11 @@ function _webform_render_grid($component
     }
     $questions = $aux;
   }
-  foreach ($questions as $question) {
+  foreach ($questions as $question => $title) {
     if ($question != '') {
       // Remove quotes from keys to prevent HTML breakage.
       $form_item[str_replace(array('"', "'"), '', $question)] = array(
-        '#title'         => $question,
+        '#title'         => $title,
         '#required'      => $component['mandatory'],
         '#prefix'        => '<div class="webform-component-'. $component['type'] .'" id="webform-component-'. $component['form_key'] .'">',
         '#suffix'        => '</div>',
@@ -165,14 +165,13 @@ function _webform_submission_display_gri
  *   Nothing
  */
 function _webform_submit_grid(&$data, $component) {
-  $options = drupal_map_assoc(array_flip(_webform_grid_options($component['extra']['options'])));
-
+  $options = drupal_map_assoc(array_keys(_webform_grid_options($component['extra']['options'])));
   // Questions are a bit more tricky, since quotes were removed from them in
   // _webform_render_grid(). Build a list of no_quotes => with_qoutes questions.
   $questions = array();
   foreach (_webform_grid_options($component['extra']['questions']) as $key => $question) {
-    $safe_question = str_replace(array('"', "'"), '', $question);
-    $questions[$safe_question] = $question;
+    $safe_question = str_replace(array('"', "'"), '', $key);
+    $questions[$safe_question] = $key;
   }
 
   if (is_array($data)) {
@@ -196,6 +195,8 @@ function _webform_submit_grid(&$data, $c
   }
 
   $data = $ordered_data;
+  
+
 }
 /**
  * Format the output of emailed data for this component.
@@ -283,7 +284,7 @@ function _webform_analysis_rows_grid($co
 
   // Add questions as each row.
   foreach ($questions as $qkey => $question) {
-    $row = array($question);
+    $row = array($qkey);
     foreach ($options as $okey => $option) {
       $row[] = !empty($counts[$qkey][$okey]) ? $counts[$qkey][$okey] : 0;
     }
