diff --git a/token.module b/token.module
index 8cf127a..3f31e5f 100644
--- a/token.module
+++ b/token.module
@@ -342,6 +342,11 @@ function token_get_values($type = 'global', $object = NULL, $flush = FALSE, $opt
   token_include();
 
   $id = _token_get_id($type, $object);
+
+  if ($id && isset($options['context'])) {
+    $id .= ':'. $options['context'];
+  }
+
   if ($id && isset($tokens[$type][$id])) {
     $tmp_tokens = $tokens[$type][$id];
   }
diff --git a/token.rules.inc b/token.rules.inc
index 3331338..bf3ebff 100644
--- a/token.rules.inc
+++ b/token.rules.inc
@@ -54,30 +54,25 @@ function token_rules_input_evaluator_prepare($string, $variables) {
  *   The current evaluation state of rules.
  */
 function token_rules_input_evaluator_apply($text, $used_vars, &$state) {
-  static $token_cache = array();
-
   if ($used_vars) {
     $vars = rules_get_variables(drupal_map_assoc(array_diff($used_vars, array(':global'))), $state);
     if ($vars === FALSE) {
-      //there not all needed variables available!
+      // Abort if needed variables are not available.
       return FALSE;
     }
     $vars[':global'] = ':global';
 
     foreach ($used_vars as $name) {
-      $type = ($name == ':global') ? 'global' : _token_rules_map_type($state['variables'][$name]->info['type']);
+      $options = array();
+      if ($name == ':global') {
+        $type = 'global';
+      }
+      else {
+        $type = _token_rules_map_type($state['variables'][$name]->info['type']);
+        $options['context'] = 'rules:'. $name;
+      }
       if ($type) {
-        $token_id = _token_get_id($type, $vars[$name]);
-        if (isset($token_cache[$token_id]) && $token_cache[$token_id] != $name) {
-          // this is the same variable in another state
-          // so we need to flush the token cache to get the fresh values
-          token_get_values('global', NULL, TRUE);
-        }
-
-        $text = token_replace($text, $type, $vars[$name], TOKEN_PREFIX. $name .':', TOKEN_SUFFIX);
-
-        // remember that this variable has been used and got cached
-        $token_cache[$token_id] = $name;
+        $text = token_replace($text, $type, $vars[$name], TOKEN_PREFIX. $name .':', TOKEN_SUFFIX, $options);
       }
     }
   }
