=== added file 'includes/path.inc'
--- /dev/null	
+++ includes/path.inc	
@@ -0,0 +1,190 @@
+<?
+
+/**
+ * @file
+ * Functions to handle paths in Drupal, including path aliasing.
+ * 
+ * These functions are not loaded for cached pages, but modules that need 
+ * to use them in hook_init() or hook exit() can make them available, by 
+ * executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);".
+ */
+
+/**
+ * Initialize the $_GET['q'] variable to the proper normal path.
+ */
+function drupal_init_path() {
+  if (!empty($_GET['q'])) {
+    $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
+  }
+  else {
+    $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
+  }
+}
+
+/**
+ * Given an alias, return its Drupal system URL if one exists. Given a Drupal
+ * system URL return its alias if one exists.
+ *
+ * @param $action
+ *   One of the following values:
+ *   - wipe: delete the alias cache.
+ *   - alias: return an alias for a given Drupal system path (if one exists).
+ *   - source: return the Drupal system URL for a path alias (if one exists).
+ * @param $path
+ *   The path to investigate for corresponding aliases or system URLs.
+ * 
+ * @return
+ *   Either a Drupal system path, an aliased path, or FALSE if no path was 
+ *   found.
+ */
+function drupal_lookup_path($action, $path = '') {
+  static $map = array();
+  static $count = NULL;
+
+  if ($count === NULL) {
+    $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
+  }
+
+  if ($action == 'wipe') {
+    $map = array();
+  }
+  elseif ($count > 0 && $path != '') {
+    if ($action == 'alias') {
+      if (isset($map[$path])) {
+        return $map[$path];
+      }
+      if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
+        $map[$path] = $alias;
+        return $alias;
+      }
+      else {
+        $map[$path] = $path;
+      }
+    }
+    elseif ($action == 'source') {
+      if ($alias = array_search($path, $map)) {
+        return $alias;
+      }
+      if (!isset($map[$path])) {
+        if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+          $map[$src] = $path;
+          return $src;
+        }
+      }
+    }
+  }
+
+  return FALSE;
+}
+
+/**
+ * Given an internal Drupal path, return the alias set by the administrator.
+ * 
+ * @param $path
+ *   An internal Drupal path.
+ * 
+ * @return
+ *   An aliased path if one was found, or the original path if no alias was 
+ *   found.
+ */
+function drupal_get_path_alias($path) {
+  $result = $path;
+  if ($alias = drupal_lookup_path('alias', $path)) {
+    $result = $alias;
+  }
+  if (function_exists('custom_url_rewrite')) {
+    $result = custom_url_rewrite('alias', $result, $path);
+  }
+  return $result;
+}
+
+/**
+ * Given a path alias, return the internal path it represents.
+ * 
+ * @param $path
+ *   A Drupal path alias.
+ * 
+ * @return
+ *   The internal path represented by the alias, or the original alias if no 
+ *   internal path was found.
+ */
+function drupal_get_normal_path($path) {
+  $result = $path;
+  if ($src = drupal_lookup_path('source', $path)) {
+    $result = $src;
+  }
+  if (function_exists('custom_url_rewrite')) {
+    $result = custom_url_rewrite('source', $result, $path);
+  }
+  return $result;
+}
+
+/**
+ * Return a component of the current Drupal path.
+ *
+ * When viewing a page at the path "admin/node/configure", for example, arg(0)
+ * would return "admin", arg(1) would return "node", and arg(2) would return
+ * "configure".
+ *
+ * Avoid use of this function where possible, as resulting code is hard to read.
+ * Instead, attempt to use named arguments in menu callback functions. See the
+ * explanation in menu.inc for how to construct callbacks that take arguments.
+ * 
+ * @param $index
+ *   The index of the component, where each component is separated by a '/' 
+ *   (forward-slash), and where the first component has an index of 0 (zero).
+ * 
+ * @return
+ *   The component specified by $index, or FALSE if the specified component was
+ *   not found.
+ */
+function arg($index) {
+  static $arguments, $q;
+
+  if (empty($arguments) || $q != $_GET['q']) {
+    $arguments = explode('/', $_GET['q']);
+    $q = $_GET['q'];
+  }
+
+  if (isset($arguments[$index])) {
+    return $arguments[$index];
+  }
+  
+  return FALSE;
+}
+
+/**
+ * Get the title of the current page, for display on the page and in the title bar.
+ * 
+ * @return
+ *   The current page's title.
+ */
+function drupal_get_title() {
+  $title = drupal_set_title();
+
+  // during a bootstrap, menu.inc is not included and thus we cannot provide a title
+  if (!isset($title) && function_exists('menu_get_active_title')) {
+    $title = check_plain(menu_get_active_title());
+  }
+
+  return $title;
+}
+
+/**
+ * Set the title of the current page, for display on the page and in the title bar.
+ * 
+ * @param $title
+ *   Optional string value to assign to the page title; or if set to NULL 
+ *   (default), leaves the current title unchanged.
+ * 
+ * @return
+ *   The updated title of the current page.
+ */
+function drupal_set_title($title = NULL) {
+  static $stored_title;
+
+  if (isset($title)) {
+    $stored_title = $title;
+  }
+  return $stored_title;
+}
=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc	
+++ includes/bootstrap.inc	
@@ -19,7 +19,8 @@ define('WATCHDOG_ERROR', 2);
 define('DRUPAL_BOOTSTRAP_DATABASE', 0);
 define('DRUPAL_BOOTSTRAP_SESSION', 1);
 define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 2);
-define('DRUPAL_BOOTSTRAP_FULL', 3);
+define('DRUPAL_BOOTSTRAP_PATH', 3);
+define('DRUPAL_BOOTSTRAP_FULL', 4);
 
 // these values should match the'role' table
 define('DRUPAL_ANONYMOUS_RID', 1);
@@ -72,12 +73,7 @@ function timer_read($name) {
 function timer_stop($name) {
   global $timers;
 
-  list($usec, $sec) = explode(' ', microtime());
-  $stop = (float)$usec + (float)$sec;
-  $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
-
-  $timers[$name]['time'] += $diff;
-
+  $timers[$name]['time'] = timer_read($name);
   unset($timers[$name]['start']);
 
   return $timers[$name];
@@ -383,46 +379,6 @@ function cache_clear_all($cid = NULL, $w
 }
 
 /**
- * Store the current page in the cache.
- *
- * We try to store a gzipped version of the cache. This requires the
- * PHP zlib extension (http://php.net/manual/en/ref.zlib.php).
- * Presence of the extension is checked by testing for the function
- * gzencode. There are two compression algorithms: gzip and deflate.
- * The majority of all modern browsers support gzip or both of them.
- * We thus only deal with the gzip variant and unzip the cache in case
- * the browser does not accept gzip encoding.
- *
- * @see drupal_page_header
- */
-function page_set_cache() {
-  global $user, $base_url;
-
-  if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET') {
-    // This will fail in some cases, see page_get_cache() for the explanation.
-    if ($data = ob_get_contents()) {
-      $cache = TRUE;
-      if (function_exists('gzencode')) {
-        // We do not store the data in case the zlib mode is deflate.
-        // This should be rarely happening.
-        if (zlib_get_coding_type() == 'deflate') {
-          $cache = FALSE;
-        }
-        else if (zlib_get_coding_type() == FALSE) {
-          $data = gzencode($data, 9, FORCE_GZIP);
-        }
-        // The remaining case is 'gzip' which means the data is
-        // already compressed and nothing left to do but to store it.
-      }
-      ob_end_flush();
-      if ($cache && $data) {
-        cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers());
-      }
-    }
-  }
-}
-
-/**
  * Retrieve the current page from the cache.
  *
  * Note, we do not serve cached pages when status messages are waiting (from
@@ -491,101 +447,6 @@ function drupal_load($type, $name) {
 }
 
 /**
- * Given an alias, return its Drupal system URL if one exists. Given a Drupal
- * system URL return its alias if one exists.
- *
- * @param $action
- *   One of the following values:
- *   - wipe: delete the alias cache.
- *   - alias: return an alias for a given Drupal system path (if one exists).
- *   - source: return the Drupal system URL for a path alias (if one exists).
- * @param $path
- *   The path to investigate for corresponding aliases or system URLs.
- */
-function drupal_lookup_path($action, $path = '') {
-  static $map = array();
-  static $count = NULL;
-
-
-  if ($count === NULL) {
-    $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
-  }
-
-  if ($action == 'wipe') {
-    $map = array();
-  }
-  elseif ($count > 0 && $path != '') {
-    if ($action == 'alias') {
-      if (isset($map[$path])) {
-        return $map[$path];
-      }
-      if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
-        $map[$path] = $alias;
-        return $alias;
-      }
-      else {
-        $map[$path] = $path;
-      }
-    }
-    elseif ($action == 'source') {
-      if ($alias = array_search($path, $map)) {
-        return $alias;
-      }
-      if (!isset($map[$path])) {
-        if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
-          $map[$src] = $path;
-          return $src;
-        }
-      }
-    }
-  }
-
-  return FALSE;
-}
-
-/**
- * Given an internal Drupal path, return the alias set by the administrator.
- */
-function drupal_get_path_alias($path) {
-  $result = $path;
-  if ($alias = drupal_lookup_path('alias', $path)) {
-    $result = $alias;
-  }
-  if (function_exists('custom_url_rewrite')) {
-    $result = custom_url_rewrite('alias', $result, $path);
-  }
-  return $result;
-}
-
-/**
- * Get the title of the current page, for display on the page and in the title bar.
- */
-function drupal_get_title() {
-  $title = drupal_set_title();
-
-  if (!isset($title)) {
-    // during a bootstrap, menu.inc is not included and thus we cannot provide a title
-    if (function_exists('menu_get_active_title')) {
-      $title = check_plain(menu_get_active_title());
-    }
-  }
-
-  return $title;
-}
-
-/**
- * Set the title of the current page, for display on the page and in the title bar.
- */
-function drupal_set_title($title = NULL) {
-  static $stored_title;
-
-  if (isset($title)) {
-    $stored_title = $title;
-  }
-  return $stored_title;
-}
-
-/**
  * Set HTTP headers in preparation for a page response.
  *
  * @see page_set_cache
@@ -685,30 +546,6 @@ function referer_uri() {
 }
 
 /**
- * Return a component of the current Drupal path.
- *
- * When viewing a page at the path "admin/node/configure", for example, arg(0)
- * would return "admin", arg(1) would return "node", and arg(2) would return
- * "configure".
- *
- * Avoid use of this function where possible, as resulting code is hard to read.
- * Instead, attempt to use named arguments in menu callback functions. See the
- * explanation in menu.inc for how to construct callbacks that take arguments.
- */
-function arg($index) {
-  static $arguments, $q;
-
-  if (empty($arguments) || $q != $_GET['q']) {
-    $arguments = explode('/', $_GET['q']);
-    $q = $_GET['q'];
-  }
-
-  if (isset($arguments[$index])) {
-    return $arguments[$index];
-  }
-}
-
-/**
  * Encode special characters in a plain-text string for display as HTML.
  */
 function check_plain($text) {
@@ -826,7 +663,7 @@ function drupal_is_denied($type, $mask) 
  *       data.
  */
 function drupal_bootstrap($phase) {
-  static $phases = array(DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_FULL);
+  static $phases = array(DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL);
 
   while (!is_null($current_phase = array_shift($phases))) {
     _drupal_bootstrap($current_phase);
@@ -872,6 +709,12 @@ function _drupal_bootstrap($phase) {
       drupal_page_header();
       break;
 
+    case DRUPAL_BOOTSTRAP_PATH:
+      require_once './includes/path.inc';
+      // Initialize $_GET['q'] prior to loading modules and invoking hook_init().
+      drupal_init_path();
+      break;
+
     case DRUPAL_BOOTSTRAP_FULL:
       require_once './includes/common.inc';
       _drupal_bootstrap_full();
@@ -894,4 +737,3 @@ function drupal_maintenance_theme() {
   unicode_check();
   $theme = '';
 }
-
=== modified file 'includes/common.inc'
--- includes/common.inc	
+++ includes/common.inc	
@@ -131,20 +131,6 @@ function drupal_clear_path_cache() {
 }
 
 /**
- * Given a path alias, return the internal path it represents.
- */
-function drupal_get_normal_path($path) {
-  $result = $path;
-  if ($src = drupal_lookup_path('source', $path)) {
-    $result = $src;
-  }
-  if (function_exists('custom_url_rewrite')) {
-    $result = custom_url_rewrite('source', $result, $path);
-  }
-  return $result;
-}
-
-/**
  * Set an HTTP response header for the current page.
  */
 function drupal_set_header($header = NULL) {
@@ -1286,13 +1272,6 @@ function _drupal_bootstrap_full() {
   drupal_set_header('Content-Type: text/html; charset=utf-8');
   // Detect string handling method
   unicode_check();
-  // Initialize $_GET['q'] prior to loading modules and invoking hook_init().
-  if (!empty($_GET['q'])) {
-    $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
-  }
-  else {
-    $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
-  }
   // Initialize all enabled modules.
   module_init();
   // Undo magic quotes
@@ -1300,3 +1279,43 @@ function _drupal_bootstrap_full() {
   // Initialize the localization system.
   $locale = locale_initialize();
 }
+
+/**
+ * Store the current page in the cache.
+ *
+ * We try to store a gzipped version of the cache. This requires the
+ * PHP zlib extension (http://php.net/manual/en/ref.zlib.php).
+ * Presence of the extension is checked by testing for the function
+ * gzencode. There are two compression algorithms: gzip and deflate.
+ * The majority of all modern browsers support gzip or both of them.
+ * We thus only deal with the gzip variant and unzip the cache in case
+ * the browser does not accept gzip encoding.
+ *
+ * @see drupal_page_header
+ */
+function page_set_cache() {
+  global $user, $base_url;
+
+  if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET') {
+    // This will fail in some cases, see page_get_cache() for the explanation.
+    if ($data = ob_get_contents()) {
+      $cache = TRUE;
+      if (function_exists('gzencode')) {
+        // We do not store the data in case the zlib mode is deflate.
+        // This should be rarely happening.
+        if (zlib_get_coding_type() == 'deflate') {
+          $cache = FALSE;
+        }
+        else if (zlib_get_coding_type() == FALSE) {
+          $data = gzencode($data, 9, FORCE_GZIP);
+        }
+        // The remaining case is 'gzip' which means the data is
+        // already compressed and nothing left to do but to store it.
+      }
+      ob_end_flush();
+      if ($cache && $data) {
+        cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers());
+      }
+    }
+  }
+}
=== modified file 'modules/statistics.module'
--- modules/statistics.module	
+++ modules/statistics.module	
@@ -62,6 +62,8 @@ function statistics_help($section) {
 function statistics_exit() {
   global $user, $recent_activity;
 
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
+
   if (variable_get('statistics_count_content_views', 0)) {
     // We are counting content views.
     if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
