diff --git a/uc_cart/uc_cart.module b/uc_cart/uc_cart.module
index 23b2ea8..8465e8c 100644
--- a/uc_cart/uc_cart.module
+++ b/uc_cart/uc_cart.module
@@ -232,10 +232,17 @@ function uc_cart_exit() {
   $this_page = request_uri();
   foreach ($pages as $page) {
     if ($page && strstr($this_page, $page) !== FALSE) {
+      if ($page != 'cart/checkout/complete') {
+        $_SESSION['uc_cart_checkout'] = REQUEST_TIME;
+      }
       cache_clear_all($base_root . $this_page, 'cache_page');
       return;
     }
   }
+
+  if (isset($_SESSION) && strstr($this_page, 'system/ajax') === FALSE) {
+    unset($_SESSION['uc_cart_checkout']);
+  }
 }
 
 /**
@@ -1441,18 +1448,18 @@ function uc_cart_add_item($nid, $qty = 1, $data = NULL, $cid = NULL, $msg = TRUE
             }
             $redirect = variable_get('uc_add_item_redirect', 'cart');
             if ($redirect != '<none>') {
-              $_SESSION['uc_cart_last_url'] = uc_referer_uri();
+              $_SESSION['uc_cart_last_url'] = request_uri();
               return $redirect;
             }
             else {
-              return uc_referer_uri();
+              return request_uri();
             }
           }
         }
         else {
           drupal_set_message($message, 'error');
         }
-        return uc_referer_uri();
+        return request_uri();
       }
     }
   }
@@ -1495,11 +1502,11 @@ function uc_cart_add_item($nid, $qty = 1, $data = NULL, $cid = NULL, $msg = TRUE
 
     $redirect = variable_get('uc_add_item_redirect', 'cart');
     if ($redirect != '<none>') {
-      $_SESSION['uc_cart_last_url'] = uc_referer_uri();
+      $_SESSION['uc_cart_last_url'] = request_uri();
       return $redirect;
     }
     else {
-      return uc_referer_uri();
+      return request_uri();
     }
   }
 }
diff --git a/uc_cart/uc_cart.pages.inc b/uc_cart/uc_cart.pages.inc
index c4f4f72..07b5abb 100644
--- a/uc_cart/uc_cart.pages.inc
+++ b/uc_cart/uc_cart.pages.inc
@@ -116,8 +116,9 @@ function uc_cart_checkout_form($form, &$form_state) {
     }
   }
 
-  // Check the referer URI to clear order details and prevent identity theft.
-  if (uc_referer_check(array('cart/checkout', 'cart/checkout/review'))) {
+  // If there hasn't been activity on checkout page for 20 minutes, clear order
+  // details and prevent identity theft.
+  if (isset($_SESSION['uc_cart_checkout']) && $_SESSION['uc_cart_checkout'] > REQUEST_TIME - 1200) {
     if ($order == FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
       unset($_SESSION['cart_order']);
       $order = NULL;
diff --git a/uc_cart_links/uc_cart_links.pages.inc b/uc_cart_links/uc_cart_links.pages.inc
index d3b6860..97466d2 100644
--- a/uc_cart_links/uc_cart_links.pages.inc
+++ b/uc_cart_links/uc_cart_links.pages.inc
@@ -145,7 +145,7 @@ function uc_cart_links_process($cart_action) {
             $rebuild_cart = TRUE;
           }
           else {
-            watchdog('uc_cart_link', 'Cart Link on %url tried to add an unpublished product to the cart.', array('%url' => uc_referer_uri()), WATCHDOG_ERROR);
+            watchdog('uc_cart_link', 'Cart Link on %url tried to add an unpublished product to the cart.', array('%url' => $_SERVER['HTTP_REFERER']), WATCHDOG_ERROR);
           }
         }
         break;
@@ -195,7 +195,7 @@ function uc_cart_links_process($cart_action) {
       ->execute();
   }
 
-  $_SESSION['uc_cart_last_url'] = uc_referer_uri();
+  $_SESSION['uc_cart_last_url'] = $_SERVER['HTTP_REFERER'];
 
   drupal_goto();
 }
diff --git a/uc_store/uc_store.module b/uc_store/uc_store.module
index 3dea2be..c7fc12b 100644
--- a/uc_store/uc_store.module
+++ b/uc_store/uc_store.module
@@ -600,33 +600,6 @@ function uc_store_page_alter(&$page) {
     '#message' => $messages[$id],
   );
 }
-
-/**
- * Implements hook_exit().
- */
-function uc_store_exit() {
-  // Don't save anything to the session if this is the first request of a session
-  if (empty($_COOKIE[session_name()])) {
-    return;
-  }
-
-  // Save the current request for tracking paths on subsequent page requests.
-  // When HTTP_REFERER is set, the session version is not; and vice versa.
-  if ($_SERVER['HTTP_REFERER'] == '') {
-    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https' : 'http';
-    $q = isset($_GET['q']) ? $_GET['q'] : '';
-    $_SESSION['uc_referer_uri'] = $protocol . '://' . $_SERVER['SERVER_NAME'] . $GLOBALS['base_path'] . $q;
-  }
-  else {
-    if (isset($_SESSION['uc_referer_uri'])) {
-      unset($_SESSION['uc_referer_uri']);
-    }
-  }
-
-  // Save the timestamp of the last access.
-  // $_SESSION['uc_last_access'] = REQUEST_TIME;
-}
-
 /**
  * Implements hook_reviews().
  *
@@ -1850,51 +1823,6 @@ function uc_store_default_country() {
 } */
 
 /**
- * Checks referers to see if they are in the allowed list.
- */
-function uc_referer_check($urls) {
-  global $base_path;
-
-  $http_referer = uc_referer_uri();
-
-  // Always return true if we have no referer; covers the case of page refreshes
-  // and switching from HTTP to HTTPS. This bypasses the two-time check below...
-  // is it safe?
-  if (empty($http_referer)) {
-    return TRUE;
-  }
-
-  // Check the user didn't shamelessly two-time us with another site.
-  $referer = parse_url($http_referer);
-  if ($referer['host'] != $_SERVER['SERVER_NAME']) {
-    return FALSE;
-  }
-
-  // Check the base path.
-  if (strncmp($referer['path'], $base_path, strlen($base_path))) {
-    return FALSE;
-  }
-
-  // Convert any path aliases.
-  $path = drupal_get_normal_path(substr($referer['path'], strlen($base_path)));
-
-  // The check itself.
-  return in_array($path, $urls);
-}
-
-/**
- * Provides a more reliable referrer for Ubercart.
- */
-function uc_referer_uri() {
-  if ($_SERVER['HTTP_REFERER'] == '') {
-    return isset($_SESSION['uc_referer_uri']) ? $_SESSION['uc_referer_uri'] : '';
-  }
-  else {
-    return $_SERVER['HTTP_REFERER'];
-  }
-}
-
-/**
  * Gets image widgets defined by various modules.
  */
 function uc_store_get_image_widgets() {
