diff --git a/autosave.js b/autosave.js
index c27522c..0d0d1ef 100644
--- a/autosave.js
+++ b/autosave.js
@@ -29,7 +29,7 @@ Drupal.behaviors.autosave.attach = function (context, settings) {
           return false;
         });
 
-        callbackPath = Drupal.settings.basePath + 'autosave/restore/' + autosaveSettings.formid + '/' + autosaveSettings.savedTimestamp + '/' + autosaveSettings.formToken;
+        callbackPath = Drupal.settings.basePath + 'autosave/restore/' + autosaveSettings.formid + '/' + autosaveSettings.savedTimestamp + '/' + autosaveSettings.formToken + '/' + autosaveSettings.theme;
         restoreLink = $('<a>').attr('href', callbackPath).addClass('use-ajax').attr('title', Drupal.t('Restore saved form')).html(Drupal.t('Restore')).click(function (e) {
           Drupal.behaviors.autosave.hideMessage();
         });
diff --git a/autosave.module b/autosave.module
index 84c89c2..185311b 100644
--- a/autosave.module
+++ b/autosave.module
@@ -50,6 +50,17 @@ function autosave_menu() {
 }
 
 /**
+ * Implements hook_custom_theme().
+ */
+function autosave_custom_theme() {
+  // Ensure that the correct theme is used when restoring a form.
+  if (strpos($_GET['q'], 'autosave/restore') === 0) {
+    $theme = arg(5);
+    return !empty($theme) ? $theme : NULL;
+  }
+}
+
+/**
  * Menu callback; return the autosave module settings form.
  */
 function autosave_admin_settings($form, &$form_state) {
@@ -87,7 +98,7 @@ function autosave_form_node_type_form_alter(&$form, $form_state) {
  * Implements hook_form_alter().
  */
 function autosave_form_alter(&$form, &$form_state, $form_id) {
-  global $user;
+  global $user, $theme;
   $path = request_path();
 
   if (stristr($form_id, '_node_form') && arg(0) != 'admin') {
@@ -107,6 +118,7 @@ function autosave_form_alter(&$form, &$form_state, $form_id) {
       $settings['autosave']['period'] = variable_get('autosave_period', 10);
       $settings['autosave']['q'] = $path;
       $settings['autosave']['hidden'] = variable_get('autosave_hidden', 0);
+      $settings['autosave']['theme'] = $theme;
 
       // If an autosaved version of the form exists, let the user know so that
       // he can restore it if desired.
