diff --git a/autosave.module b/autosave.module
index 9266803..a0809ce 100644
--- a/autosave.module
+++ b/autosave.module
@@ -165,6 +165,17 @@ function autosave_restore($formid, $timestamp) {
       require_once DRUPAL_ROOT . '/' . $menu_item['include_file'];
     }
     $form_state['input'] = unserialize($record->serialized);
+
+    // We need a node object and not just a string with the node's type.
+    // Later in the node module is a hook that needs a drupal node object
+    // as its first argument. The node object is constructed in the following
+    // from the type string.
+    $type = $menu_item['page_arguments'][0];
+    //$node = (object) array('type'=>$type);
+    $node = new stdClass();
+    $node->type = $type;
+    node_object_prepare($node);
+    $menu_item['page_arguments'][0] = $node;
     $form_state['build_info']['args'] = $menu_item['page_arguments'];
     // Disable the "this form has already been submitted" nonsense by making
     // Drupal think the form is being rebuilt as part of a multi-step form.
@@ -272,10 +283,9 @@ function autosave_save() {
   }
   else {
     // add case
-    $submitted->changed = db_query("SELECT created FROM {node} WHERE uid = :uid and type = :type ORDER BY created DESC LIMIT 1", array(
+    $submitted->changed = db_query_range("SELECT created FROM {node} WHERE uid = :uid and type = :type ORDER BY created DESC", 0, 1, array(
       ':uid' => $user->uid,
-      ':type' => str_replace("-", "_", $path_args[2]))
-    )->fetchField();
+      ':type' => str_replace("-", "_", $path_args[2])))->fetchField();
   }
 
   if (!$submitted || (REQUEST_TIME - $submitted->changed) > 10) {
