diff --git a/webform_tokens.module b/webform_tokens.module
index 61b7438..561579f 100644
--- a/webform_tokens.module
+++ b/webform_tokens.module
@@ -5,6 +5,17 @@
  * The Webform Tokens module.
  */
 
+function webform_tokens_guess_webform_version() {
+  // A pretty reliable test is the "submission" token type.
+  $token_info = token_info();
+
+  if (isset($token_info['types']['submission'])) {
+    return 4;
+  }
+
+  return 3;
+}
+
 /**
  * Implements hook_token_info().
  */
@@ -232,6 +243,8 @@ function _webform_tokens_add_component_replacement($component, $submission, $tok
   $nid = $submission->nid;
   $sid = $submission->sid;
 
+  $component_value = _webform_tokens_extract_component_value($component);
+
   // If this is a request for a label token, no need for all the other stuff.
   if ($token_data['name'] == 'meta-label-' . $component['form_key']) {
     $replacements[$token_data['original']] = $component['name'];
@@ -264,7 +277,7 @@ function _webform_tokens_add_component_replacement($component, $submission, $tok
   }
   if ($options) {
     $component['extra']['options'] = $options;
-    foreach ($component['value'] as $chain_value) {
+    foreach ($component_value as $chain_value) {
       if (isset($options[$chain_value])) {
         $values[$chain_value] = $options[$chain_value];
       }
@@ -287,29 +300,29 @@ function _webform_tokens_add_component_replacement($component, $submission, $tok
     $component['extra']['options'] = FALSE;
   }
 
-  if (!empty($component['value']) && is_array($component['value'])) {
+  if (!empty($component_value) && is_array($component_value)) {
     switch ($component['type']) {
       case 'date':
         // Chain tokens.
         if ($found_tokens = token_find_with_prefix($token_data['tokens'], 'val-' . $component['form_key'])) {
-          return token_generate('date', $found_tokens, array('date' => strtotime($component['value'][0])), $token_data['options']);
+          return token_generate('date', $found_tokens, array('date' => strtotime($component_value[0])), $token_data['options']);
         }
         if ($found_tokens = token_find_with_prefix($token_data['tokens'], 'webform-val-' . $component['form_key'])) {
-          return token_generate('date', $found_tokens, array('date' => strtotime($component['value'][0])), $token_data['options']);
+          return token_generate('date', $found_tokens, array('date' => strtotime($component_value[0])), $token_data['options']);
         }
         // Non-chain token: Format date the same way Webform does.
-        $value = webform_date_array($component['value'][0], 'date');
+        $value = webform_date_array($component_value[0], 'date');
         $value = theme('webform_display_date', array('element' => array('#value' => $value)));
         break;
       case 'file':
-        $file = file_load((int)$component['value'][0]);
+        $file = file_load((int)$component_value[0]);
         $value = file_create_url($file->uri);
         break;
       case 'select':
       case 'grid':
         // Make key token
         $fullvalue = array();
-        foreach ($component['value'] as $value) {
+        foreach ($component_value as $value) {
           if ($token_data['name'] == 'webform-key-' . $component['form_key']) {
             $array_part = 'key';
           }
@@ -329,7 +342,7 @@ function _webform_tokens_add_component_replacement($component, $submission, $tok
         // Usually there is only one value, so implode just removes the array
         // Otherwise, separate the values with a comma
         // @todo: There should probably be better handling for multiple values
-        $value = implode(', ', $component['value']);
+        $value = implode(', ', $component_value);
     }
   }
   else {
@@ -346,6 +359,27 @@ function _webform_tokens_add_component_replacement($component, $submission, $tok
   return $replacements;
 }
 
+function _webform_tokens_extract_component_value(array $component) {
+  // If Webform 3.x, just return $component['value']
+  if (webform_tokens_guess_webform_version() != 4) {
+    return $component['value'];
+  }
+
+  if (isset($component) === FALSE) {
+    return array();
+  }
+
+  $return = array();
+
+  foreach ($component as $key => $value) {
+    if (is_int($key)) {
+      $return[$key] = $value;
+    }
+  }
+
+  return $return;
+}
+
 /*
  * Clear the token cache when Webform components are updated.
  */
@@ -370,3 +404,4 @@ function webform_tokens_webform_component_update() {
 function webform_tokens_webform_component_delete() {
   token_clear_cache();
 }
+
