diff --git a/filefield_paths.module b/filefield_paths.module
index 4f7b87257e1a72e53a5beebac385dbd986541c10..5298cda4210902488fa7e7cc6070202350b99d2c 100644
--- a/filefield_paths.module
+++ b/filefield_paths.module
@@ -267,8 +267,20 @@ function filefield_paths_entity_update($entity, $type) {
     }
 
     if ($processed) {
+      if (isset($entity->revision)) {
+        // Remember revision flag.
+        $revision = $entity->revision;
+        // Remove revision flag as long as fields already processed it, and no need
+        // to create new revision for moved files.
+        $entity->revision = FALSE;
+      }
+      // Save any changes back to the database.
       $entity->original = isset($entity->original) ? $entity->original : NULL;
       field_attach_update($type, $entity);
+      if (isset($entity->revision)) {
+        // Restore revision flag so that other modules can process it if needed.
+        $entity->revision = $revision;
+      }
     }
   }
 }
@@ -362,40 +374,41 @@ function _filefield_paths_replace_image_derivative_token($old_uri, $new_uri, $qu
  * Process and cleanup strings.
  */
 function filefield_paths_process_string($value, $data, $settings = array()) {
-  $transliterate = module_exists('transliteration') && isset($settings['transliterate']) && $settings['transliterate'];
-  $pathauto = module_exists('pathauto') && isset($settings['pathauto']) && $settings['pathauto'] == TRUE;
+  // Process string tokens. Use callback to process each token separately.
+  $settings += array(
+    'clear' => TRUE,
+    'callback' => '_filefield_paths_process_tokens',
+  );
+  $value = token_replace($value, $data, $settings);
+
+  // Ensure that there are no double-slash sequences due to empty token values.
+  $value = preg_replace('/\/+/', '/', $value);
+
+  return $value;
+}
+
+/**
+ * Token replacement callback.
+ */
+function _filefield_paths_process_tokens(&$replacements, $data, $options) {
+  $transliterate = module_exists('transliteration') && isset($options['transliterate']) && $options['transliterate'];
+  $pathauto = module_exists('pathauto') && isset($options['pathauto']) && $options['pathauto'] == TRUE;
   if ($pathauto == TRUE) {
     module_load_include('inc', 'pathauto');
   }
 
-  // Process string tokens.
-  $value = token_replace($value, $data, array('clear' => TRUE));
-
-  $paths = explode('/', $value);
-  foreach ($paths as $i => &$path) {
-
-    // Cleanup with pathauto.
-    if ($pathauto == TRUE) {
-      if ('file_name' == $settings['context'] && count($paths) == $i + 1) {
-        $pathinfo = pathinfo($path);
-        $path = str_replace($pathinfo['filename'], pathauto_cleanstring($pathinfo['filename']), $path);
+  if ($pathauto || $transliterate) {
+    foreach ($replacements as $token => $value) {
+      // Replace using pathauto settings.
+      if ($pathauto == TRUE) {
+        $replacements[$token] = pathauto_cleanstring($replacements[$token]);
       }
-      else {
-        $path = pathauto_cleanstring($path);
+      // Replace using transliteration settings.
+      if ($transliterate == TRUE) {
+        $replacements[$token] = transliteration_clean_filename($replacements[$token]);
       }
     }
-
-    // Transliterate string.
-    if ($transliterate == TRUE) {
-      $path = transliteration_clean_filename($path);
-    }
   }
-  $value = implode('/', $paths);
-
-  // Ensure that there are no double-slash sequences due to empty token values.
-  $value = preg_replace('/\/+/', '/', $value);
-
-  return $value;
 }
 
 /**
