=== modified file 'includes/common.inc'
--- includes/common.inc	
+++ includes/common.inc	
@@ -255,6 +255,9 @@ function drupal_not_found() {
   drupal_set_header('HTTP/1.0 404 Not Found');
   watchdog('page not found', t('%page not found.', array('%page' => theme('placeholder', $_GET['q']))), WATCHDOG_WARNING);
 
+  // Keep old path for reference
+  $_REQUEST['destination'] = $_GET['q'];
+
   $path = drupal_get_normal_path(variable_get('site_404', ''));
   if ($path && $path != $_GET['q']) {
     menu_set_active_item($path);
@@ -262,7 +265,7 @@ function drupal_not_found() {
   }
   else {
     // Redirect to a non-existant menu item to make possible tabs disappear.
-    menu_set_active_item('#');
+    menu_set_active_item('^');
   }
 
   if (empty($return)) {
@@ -278,6 +281,9 @@ function drupal_access_denied() {
   drupal_set_header('HTTP/1.0 403 Forbidden');
   watchdog('access denied', t('%page denied access.', array('%page' => theme('placeholder', $_GET['q']))), WATCHDOG_WARNING, l(t('view'), $_GET['q']));
 
+  // Keep old path for reference
+  $_REQUEST['destination'] = $_GET['q'];
+
   $path = drupal_get_normal_path(variable_get('site_403', ''));
   if ($path && $path != $_GET['q']) {
     menu_set_active_item($path);
@@ -285,7 +291,7 @@ function drupal_access_denied() {
   }
   else {
     // Redirect to a non-existant menu item to make possible tabs disappear.
-    menu_set_active_item('#');
+    menu_set_active_item('^');
   }
 
   if (empty($return)) {
