diff --git a/core/modules/statistics/lib/Drupal/statistics/DatabaseStatisticsBackend.php b/core/modules/statistics/lib/Drupal/statistics/DatabaseStatisticsBackend.php
new file mode 100644
index 0000000..3115f5e
--- /dev/null
+++ b/core/modules/statistics/lib/Drupal/statistics/DatabaseStatisticsBackend.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * Definition of Drupal\statistics\StatisticsBackend.
+ */
+
+namespace Drupal\statistics;
+
+use Drupal\statistics\StatisticsBackendInterface;
+
+/**
+ * @todo Add proper documentation.
+ */
+class DatabaseStatisticsBackend implements StatisticsBackendInterface {
+
+  public function save($nid) {
+    db_merge('node_counter')
+       ->key(array('nid' => $nid))
+       ->fields(array(
+         'daycount' => 1,
+         'totalcount' => 1,
+         'timestamp' => REQUEST_TIME,
+       ))
+       ->expression('daycount', 'daycount + 1')
+       ->expression('totalcount', 'totalcount + 1')
+       ->execute();
+  }
+  
+  public function get($nid) {
+    if ($nid > 0) {
+      // Retrieve an array with both totalcount and daycount.
+      return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
+    }  
+  }
+  
+  public function delete($nid) {
+    db_delete('node_counter')
+      ->condition('nid', $nid)
+      ->execute();
+  }
+  
+}
\ No newline at end of file
diff --git a/core/modules/statistics/lib/Drupal/statistics/StatisticsBackendInterface.php b/core/modules/statistics/lib/Drupal/statistics/StatisticsBackendInterface.php
new file mode 100644
index 0000000..bfd6352
--- /dev/null
+++ b/core/modules/statistics/lib/Drupal/statistics/StatisticsBackendInterface.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Definition of Drupal\statistics\StatisticsBackendInterface.
+ */
+
+namespace Drupal\statistics;
+
+/**
+ * @todo Add proper documentation.
+ */
+interface StatisticsBackendInterface {
+
+  public function save($nid);
+  
+  public function get($nid);
+  
+  public function delete($nid);
+
+}
\ No newline at end of file
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index ef1bceb..4dbd0ff 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -44,6 +44,18 @@ function statistics_help($path, $arg) {
 }
 
 /**
+ * Implements hook_init().
+ */
+function statistics_init() {
+  // Define the mappings to the statistics wrapper. We register this in
+  // the Drupal container so that it can be re-registered with a
+  // different backend later on.
+  $class = variable_get('statistics_backend', 'Drupal\\statistics\\DatabaseStatisticsBackend');
+  $container = drupal_container();
+  $container->register('statistics', $class);
+}
+
+/**
  * Implements hook_exit().
  *
  * Gathers statistics for page accesses.
@@ -299,11 +311,7 @@ function statistics_title_list($dbfield, $dbrows) {
  *   - timestamp: Integer for the timestamp of when the node was last viewed.
  */
 function statistics_get($nid) {
-
-  if ($nid > 0) {
-    // Retrieve an array with both totalcount and daycount.
-    return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
-  }
+  return drupal_container()->get('statistics')->get($nid);
 }
 
 /**
@@ -414,9 +422,7 @@ function _statistics_format_item($title, $path) {
  */
 function statistics_node_predelete(Node $node) {
   // clean up statistics table when node is deleted
-  db_delete('node_counter')
-    ->condition('nid', $node->nid)
-    ->execute();
+  drupal_container()->get('statistics')->delete($node->nid);
 }
 
 /**
diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php
index 040dc19..36d4634 100644
--- a/core/modules/statistics/statistics.php
+++ b/core/modules/statistics/statistics.php
@@ -14,20 +14,11 @@ chdir('../../..');
 define('DRUPAL_ROOT', getcwd());
 
 include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
 if (variable_get('statistics_count_content_views', 0)) {
   $nid = $_POST['nid'];
   if (is_numeric($nid)) {
-    db_merge('node_counter')
-      ->key(array('nid' => $nid))
-      ->fields(array(
-        'daycount' => 1,
-        'totalcount' => 1,
-        'timestamp' => REQUEST_TIME,
-      ))
-      ->expression('daycount', 'daycount + 1')
-      ->expression('totalcount', 'totalcount + 1')
-      ->execute();
+    drupal_container()->get('statistics')->save($nid);
   }
-}
-
+}
\ No newline at end of file
