diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 7c6ca09..4605db2 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2321,6 +2321,7 @@ function _drupal_bootstrap_variables() {
 
   // Load variables from the database, but do not overwrite variables set in settings.php.
   $conf = variable_initialize(isset($conf) ? $conf : array());
+
   // Load bootstrap modules.
   require_once DRUPAL_ROOT . '/includes/module.inc';
   module_load_all(TRUE);
diff --git a/includes/cache-install.inc b/includes/cache-install.inc
deleted file mode 100644
index 8bcf8b7..0000000
--- a/includes/cache-install.inc
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-/**
- * @file
- * Provides a stub cache implementation to be used during installation.
- */
-
-/**
- * A stub cache implementation to be used during the installation process.
- *
- * The stub implementation is needed when database access is not yet available.
- * Because Drupal's caching system never requires that cached data be present,
- * these stub functions can short-circuit the process and sidestep the need for
- * any persistent storage. Obviously, using this cache implementation during
- * normal operations would have a negative impact on performance.
- */
-class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
-  function get($cid) {
-    return FALSE;
-  }
-
-  function getMultiple(&$cids) {
-    return array();
-  }
-
-  function set($cid, $data, $expire = CACHE_PERMANENT) {
-  }
-
-  function deletePrefix($cid) {
-    try {
-      if (class_exists('Database')) {
-        parent::deletePrefix($cid);
-      }
-    }
-    catch (Exception $e) {
-    }
-  }
-
-  function clear($cid = NULL, $wildcard = FALSE) {
-    // If there is a database cache, attempt to clear it whenever possible. The
-    // reason for doing this is that the database cache can accumulate data
-    // during installation due to any full bootstraps that may occur at the
-    // same time (for example, Ajax requests triggered by the installer). If we
-    // didn't try to clear it whenever this function is called, the data in the
-    // cache would become stale; for example, the installer sometimes calls
-    // variable_set(), which updates the {variable} table and then clears the
-    // cache to make sure that the next page request picks up the new value.
-    // Not actually clearing the cache here therefore leads old variables to be
-    // loaded on the first page requests after installation, which can cause
-    // subtle bugs, some of which would not be fixed unless the site
-    // administrator cleared the cache manually.
-    try {
-      if (class_exists('Database')) {
-        parent::clear($cid, $wildcard);
-      }
-    }
-    // If the attempt at clearing the cache causes an error, that means that
-    // either the database connection is not set up yet or the relevant cache
-    // table in the database has not yet been created, so we can safely do
-    // nothing here.
-    catch (Exception $e) {
-    }
-  }
-
-  function isEmpty() {
-    return TRUE;
-  }
-}
diff --git a/includes/cache.inc b/includes/cache.inc
index 9b60a7e..8068012 100644
--- a/includes/cache.inc
+++ b/includes/cache.inc
@@ -348,6 +348,50 @@ interface DrupalCacheInterface {
 }
 
 /**
+ * A stub cache implementation.
+ *
+ * The stub implementation is needed when database access is not yet available.
+ * Because Drupal's caching system never requires that cached data be present,
+ * these stub functions can short-circuit the process and sidestep the need for
+ * any persistent storage. Obviously, using this cache implementation during
+ * normal operations would have a negative impact on performance.
+ * 
+ * This also can be used for testing purposes.
+ */
+class DrupalFakeCache implements DrupalCacheInterface {
+
+  function __construct($bin) {}
+
+  function get($cid) {
+    return FALSE;
+  }
+
+   function getMultiple(&$cids) {
+     return array();
+   }
+
+  function set($cid, $data, $expire = CACHE_PERMANENT) {}
+
+  function delete($cid) {}
+
+  function deleteMultiple(array $cids) {}
+
+  function deletePrefix($prefix) {}
+
+  function flush() {}
+
+  function expire() {}
+
+  function garbageCollection() {}
+
+  function clear($cid = NULL, $wildcard = FALSE) {}
+
+  function isEmpty() {
+    return TRUE;
+  }
+}
+
+/**
  * Default cache implementation.
  *
  * This is Drupal's default cache implementation. It uses the database to store
diff --git a/includes/install.core.inc b/includes/install.core.inc
index 3791d71..7ed67a9 100644
--- a/includes/install.core.inc
+++ b/includes/install.core.inc
@@ -272,7 +272,6 @@ function install_begin_request(&$install_state) {
   // because any data put in the cache during the installer is inherently
   // suspect, due to the fact that Drupal is not fully set up yet.
   require_once DRUPAL_ROOT . '/includes/cache.inc';
-  require_once DRUPAL_ROOT . '/includes/cache-install.inc';
   $conf['cache_default_class'] = 'DrupalFakeCache';
 
   // Prepare for themed output. We need to run this at the beginning of the
@@ -754,6 +753,11 @@ function install_system_module(&$install_state) {
   // Install system.module.
   drupal_install_system();
 
+  // Fully disable cache while installing. When reaching here, parallel AJAX
+  // requests are not supposed to be started. Now that system module has been
+  // installed, this variable will go right to the database.
+  variable_set('cache_default_class', 'DrupalFakeCache');
+
   // Enable the user module so that sessions can be recorded during the
   // upcoming bootstrap step.
   module_enable(array('user'), FALSE);
@@ -1494,10 +1498,15 @@ function install_finished(&$install_state) {
   $output = '<p>' . st('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())) . '</p>';
   $output .= '<p>' . (isset($messages['error']) ? st('Review the messages above before visiting <a href="@url">your new site</a>.', array('@url' => url(''))) : st('<a href="@url">Visit your new site</a>.', array('@url' => url('')))) . '</p>';
 
-  // Flush all caches to ensure that any full bootstraps during the installer
-  // do not leave stale cached data, and that any content types or other items
-  // registered by the install profile are registered correctly.
-  drupal_flush_all_caches();
+  // Now that the installation is finished, we can restore DrupalDatabaseCache
+  // as default backend, and ensure we don't leave the site with no cache at
+  // all. Now all parallel AJAX requests are done, we won't risk cache entries
+  // to stall anymore. Do it before con run and misc. variable_*() calls to
+  // ensure cache backends has not been boostrapped yet.
+  if ('DrupalFakeCache' === variable_get('cache_default_class')) {
+    // Delete it only if no other installation task changed it over us.
+    variable_del('cache_default_class');
+  }
 
   // Remember the profile which was used.
   variable_set('install_profile', drupal_get_profile());
