diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 56e5f43..7bf1ac4 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2400,22 +2400,24 @@ function drupal_get_bootstrap_phase() {
  *
  * @see Drupal\Core\DrupalKernel
  *
+ * @param $new_container
+ *   A new container instance to store.
  * @param $reset
- *   A new container instance to reset the Drupal container to.
+ *   Set to TRUE to create a new bare essentials container.
  *
  * @return Symfony\Component\DependencyInjection\Container
  *   The instance of the Container used to set up and maintain object
  *   instances.
  */
-function drupal_container(Container $reset = NULL) {
+function drupal_container(Container $new_container = NULL, $reset = FALSE) {
   // We do not use drupal_static() here because we do not have a mechanism by
   // which to reinitialize the stored objects, so a drupal_static_reset() call
   // would leave Drupal in a nonfunctional state.
   static $container = NULL;
-  if (isset($reset)) {
-    $container = $reset;
+  if ($new_container || $reset) {
+    $container = $new_container;
   }
-  elseif (!isset($container)) {
+  if (!isset($container)) {
     // Return a ContainerBuilder instance with the bare essentials needed for any
     // full bootstrap regardless of whether there will be a DrupalKernel involved.
     // This will get merged with the full Kernel-built Container on normal page
diff --git a/core/includes/file.inc b/core/includes/file.inc
index ed4bdce..da3b9cb 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -2025,7 +2025,9 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
 
   $options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
   $files = array();
-  if (is_dir($dir) && $handle = opendir($dir)) {
+  // Avoid warnings when opendir does not have the permissions to open a
+  // directory.
+  if (is_dir($dir) && $handle = @opendir($dir)) {
     while (FALSE !== ($filename = readdir($handle))) {
       if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') {
         $uri = "$dir/$filename";
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index e53e895..4afcc58 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1404,7 +1404,7 @@ function install_bootstrap_full(&$install_state) {
   // e.g. 'prod', 'dev', and a boolean indicating whether it is in debug mode.
   // Drupal does not currently make use of either of these, though that may
   // change with http://drupal.org/node/1537198.
-  $kernel = new DrupalKernel('prod', FALSE);
+  $kernel = new DrupalKernel('prod', FALSE, system_list());
   $kernel->boot();
   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 }
diff --git a/core/includes/module.inc b/core/includes/module.inc
index ab45576..a104993 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -115,13 +115,13 @@ function module_list_reset() {
  * @see module_list()
  * @see list_themes()
  */
-function system_list($type) {
+function system_list($type = NULL) {
   $lists = &drupal_static(__FUNCTION__);
 
   // For bootstrap modules, attempt to fetch the list from cache if possible.
   // if not fetch only the required information to fire bootstrap hooks
   // in case we are going to serve the page from cache.
-  if ($type == 'bootstrap') {
+  if ($type === 'bootstrap') {
     if (isset($lists['bootstrap'])) {
       return $lists['bootstrap'];
     }
@@ -175,6 +175,7 @@ function system_list($type) {
           $lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
         }
       }
+      $lists['module_enabled_hash'] = hash('sha256', implode(',', array_keys($lists['module_enabled'])));
       foreach ($lists['theme'] as $key => $theme) {
         if (!empty($theme->info['base theme'])) {
           // Make a list of the theme's base themes.
@@ -209,7 +210,7 @@ function system_list($type) {
     }
   }
 
-  return $lists[$type];
+  return $type ? $lists[$type] : $lists;
 }
 
 /**
diff --git a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
index 3d1bd95..81a155c 100644
--- a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
@@ -69,4 +69,11 @@ class FileReadOnlyStorage implements PhpStorageInterface {
   protected function getFullPath($name) {
     return $this->directory . '/' . $name;
   }
+
+  /**
+   * Implements Drupal\Component\PhpStorage\PhpStorageInterface::writeable().
+   */
+  function writeable() {
+    return FALSE;
+  }
 }
diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
index 80f3ec4..1f690f9 100644
--- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
@@ -71,4 +71,11 @@ class FileStorage implements PhpStorageInterface {
   protected function getFullPath($name) {
     return $this->directory . '/' . $name;
   }
+
+  /**
+   * Implements Drupal\Component\PhpStorage\PhpStorageInterface::writeable().
+   */
+  function writeable() {
+    return TRUE;
+  }
 }
diff --git a/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php b/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php
index 1eaece3..8b5e271 100644
--- a/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php
+++ b/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php
@@ -57,6 +57,13 @@ interface PhpStorageInterface {
   public function save($name, $code);
 
   /**
+   * Whether this is a writeable storage.
+   *
+   * @return bool
+   */
+  public function writeable();
+
+  /**
    * Deletes PHP code from storage.
    *
    * @param string $name
diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php
index 2c5d180..06bdd72 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -52,24 +52,6 @@ class CoreBundle extends Bundle
       ->setFactoryMethod('getConnection')
       ->addArgument('slave');
 
-    // @todo Replace below lines with the commented out block below it when it's
-    //   performant to do so: http://drupal.org/node/1706064.
-    $dispatcher = $container->get('dispatcher');
-    $matcher = new \Drupal\Core\LegacyUrlMatcher();
-    $content_negotation = new \Drupal\Core\ContentNegotiation();
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\RouterListener($matcher));
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\ViewSubscriber($content_negotation));
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\AccessSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\PathSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\LegacyRequestSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\LegacyControllerSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\FinishResponseSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\RequestCloseSubscriber());
-    $dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber());
-    $container->set('content_negotiation', $content_negotation);
-    $dispatcher->addSubscriber(\Drupal\Core\ExceptionController::getExceptionListener($container));
-    /*
     $container->register('matcher', 'Drupal\Core\LegacyUrlMatcher');
     $container->register('router_listener', 'Drupal\Core\EventSubscriber\RouterListener')
       ->addArgument(new Reference('matcher'))
@@ -94,7 +76,8 @@ class CoreBundle extends Bundle
       ->addTag('kernel.event_subscriber');
     $container->register('request_close_subscriber', 'Drupal\Core\EventSubscriber\RequestCloseSubscriber')
       ->addTag('kernel.event_subscriber');
-    $container->register('config_global_override_subscriber', '\Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber');
+    $container->register('config_global_override_subscriber', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber')
+      ->addTag('kernel.event_subscriber');
     $container->register('exception_listener', 'Symfony\Component\HttpKernel\EventListener\ExceptionListener')
       ->addTag('kernel.event_subscriber')
       ->addArgument(new Reference('service_container'))
@@ -103,6 +86,5 @@ class CoreBundle extends Bundle
 
     // Add a compiler pass for registering event subscribers.
     $container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
-    */
   }
 }
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 869d4ee..7cf2908 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -8,10 +8,12 @@
 namespace Drupal\Core;
 
 use Drupal\Core\CoreBundle;
+use Drupal\Component\PhpStorage\PhpStorageInterface;
 use Symfony\Component\HttpKernel\Kernel;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Symfony\Component\Config\Loader\LoaderInterface;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
+use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 
 /**
  * The DrupalKernel class is the core of Drupal itself.
@@ -26,6 +28,16 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 class DrupalKernel extends Kernel {
 
   /**
+   * @var array The name of the container class.
+   */
+  protected $systemList;
+
+  public function __construct($environment, $debug, $system_list) {
+    parent::__construct($environment, $debug);
+    $this->systemList = $system_list;
+  }
+
+  /**
    * Overrides Kernel::init().
    */
   public function init() {
@@ -43,9 +55,7 @@ class DrupalKernel extends Kernel {
       new CoreBundle(),
     );
 
-    // @todo Remove the necessity of calling system_list() to find out which
-    // bundles exist. See http://drupal.org/node/1331486
-    $modules = array_keys(system_list('module_enabled'));
+    $modules = array_keys($this->systemList['module_enabled']);
     foreach ($modules as $module) {
       $camelized = ContainerBuilder::camelize($module);
       $class = "Drupal\\{$module}\\{$camelized}Bundle";
@@ -61,11 +71,37 @@ class DrupalKernel extends Kernel {
    * Initializes the service container.
    */
   protected function initializeContainer() {
-    // @todo We should be compiling the container and dumping to php so we don't
-    //   have to recompile every time. There is a separate issue for this, see
-    //   http://drupal.org/node/1668892.
-    $this->container = $this->buildContainer();
+    // While the default Symfony class name only depends on the environment,
+    // for testing purposes we can't use that because there would be a
+    // collission as each test method creates a new kernel. On the other hand,
+    // the container only depends on the enabled modules (and only on those
+    // that provide bundles) so we base the name of the container class on
+    // the hash of the enabled modules. We can't use directly the hash though
+    // because PHP identifiers always start with a letter and hashes don't so
+    // we add a charater to the beginning. This mechanism also avoids the
+    // problem of needing to rebuild the DIC at the right time on module
+    // enable: simply on the next request the hash will change and so the
+    // container will be rebuilt.
+    $class = 'c' . $this->systemList['module_enabled_hash'];
+    $cache_file = $class . '.php';
+
+    $storage = drupal_php_storage('service_container');
+    // First, try to load.
+    if (!class_exists($class)) {
+      $storage->load($cache_file);
+    }
+    // If the load succeeded or the class already existed, use it.
+    if (class_exists($class)) {
+      $this->container = new $class;
+    }
+    else {
+      $this->container = $this->buildContainer();
+      if ($storage->writeable()) {
+        $this->dumpDrupalContainer($cache_file, $this->container, $class, $this->getContainerBaseClass(), $storage);
+      }
+    }
     $this->container->set('kernel', $this);
+
     drupal_container($this->container);
   }
 
@@ -84,10 +120,7 @@ class DrupalKernel extends Kernel {
     foreach ($this->bundles as $bundle) {
       $bundle->build($container);
     }
-
-    // @todo Compile the container: http://drupal.org/node/1706064.
-    //$container->compile();
-
+    $container->compile();
     return $container;
   }
 
@@ -101,6 +134,31 @@ class DrupalKernel extends Kernel {
   }
 
   /**
+   * Dumps the service container to PHP code in the config directory.
+   *
+   * This method is based on the dumpContinaer method in the parent class, but
+   * that method is reliant on the Config component which we do not use here.
+   *
+   * @param string           $cache_file     The full filename to write to.
+   * @param ContainerBuilder $container The service container
+   * @param string           $class     The name of the class to generate
+   * @param string           $baseClass The name of the container's base class
+   * @param PhpStorageInterface $storage The php storage class
+   */
+  protected function dumpDrupalContainer($cache_file, ContainerBuilder $container, $class, $baseClass, PhpStorageInterface $storage)
+  {
+    // cache the container
+    $dumper = new PhpDumper($container);
+    $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
+
+    if (!$this->debug) {
+      $content = self::stripComments($content);
+    }
+
+    $storage->save($cache_file, $content);
+  }
+
+  /**
    * Overrides and eliminates this method from the parent class. Do not use.
    *
    * This method is part of the KernelInterface interface, but takes an object
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index 8065349..e341e46 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\EventSubscriber;
 
+use Drupal\Core\Language\LanguageManager;
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\HttpKernel\KernelEvents;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -16,6 +17,12 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  */
 class FinishResponseSubscriber implements EventSubscriberInterface {
 
+  protected $language_manager;
+
+  public function __construct(LanguageManager $language_manager) {
+    $this->language_manager = $language_manager;
+  }
+
   /**
    * Sets extra headers on successful responses.
    *
@@ -30,10 +37,7 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
     $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', false);
 
     // Set the Content-language header.
-    // @todo Receive the LanguageManager object as a constructor argument when
-    //   the dependency injection container allows for it performantly:
-    //   http://drupal.org/node/1706064.
-    $response->headers->set('Content-language', language(LANGUAGE_TYPE_INTERFACE)->langcode);
+    $response->headers->set('Content-language', $this->language_manager->getLanguage(LANGUAGE_TYPE_INTERFACE)->langcode);
 
     // Because pages are highly dynamic, set the last-modified time to now
     // since the page is in fact being regenerated right now.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 25139e6..48bc83b 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -670,7 +670,8 @@ abstract class WebTestBase extends TestBase {
     // container in drupal_container(). Drupal\simpletest\TestBase::tearDown()
     // restores the original container.
     // @see Drupal\Core\DrupalKernel::initializeContainer()
-    $this->kernel = new DrupalKernel('testing', FALSE);
+    drupal_container(NULL, TRUE);
+    $this->kernel = new DrupalKernel('testing', FALSE, system_list());
     // Booting the kernel is necessary to initialize the new DIC. While
     // normally the kernel gets booted on demand in
     // Symfony\Component\HttpKernel\handle(), this kernel needs manual booting
diff --git a/core/modules/system/tests/http.php b/core/modules/system/tests/http.php
index 297e3c7..313c4c0 100644
--- a/core/modules/system/tests/http.php
+++ b/core/modules/system/tests/http.php
@@ -36,6 +36,6 @@ $request = Request::createFromGlobals();
 
 drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
 
-$kernel = new DrupalKernel('prod', FALSE);
+$kernel = new DrupalKernel('prod', FALSE, system_list());
 $response = $kernel->handle($request)->prepare($request)->send();
 $kernel->terminate($request, $response);
diff --git a/core/modules/system/tests/https.php b/core/modules/system/tests/https.php
index 369116d..edfda57 100644
--- a/core/modules/system/tests/https.php
+++ b/core/modules/system/tests/https.php
@@ -35,6 +35,6 @@ $request = Request::createFromGlobals();
 
 drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
 
-$kernel = new DrupalKernel('prod', FALSE);
+$kernel = new DrupalKernel('prod', FALSE, system_list());
 $response = $kernel->handle($request)->prepare($request)->send();
 $kernel->terminate($request, $response);
diff --git a/core/modules/system/tests/modules/bundle_test/lib/Drupal/bundle_test/BundleTestBundle.php b/core/modules/system/tests/modules/bundle_test/lib/Drupal/bundle_test/BundleTestBundle.php
index 768a1b0..c124007 100644
--- a/core/modules/system/tests/modules/bundle_test/lib/Drupal/bundle_test/BundleTestBundle.php
+++ b/core/modules/system/tests/modules/bundle_test/lib/Drupal/bundle_test/BundleTestBundle.php
@@ -20,9 +20,5 @@ class BundleTestBundle extends Bundle
   public function build(ContainerBuilder $container) {
     $container->register('bundle_test_class', 'Drupal\bundle_test\TestClass')
       ->addTag('kernel.event_subscriber');
-
-    // @todo Remove when the 'kernel.event_subscriber' tag above is made to
-    //   work: http://drupal.org/node/1706064.
-    $container->get('dispatcher')->addSubscriber($container->get('bundle_test_class'));
   }
 }
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 62107ab..c5eb216 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -479,7 +479,7 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) {
     // simpletest_clean_temporary_directories() cannot be used here, since it
     // would also delete file directories of other tests that are potentially
     // running concurrently.
-    file_unmanaged_delete_recursive($test_directory);
+    file_unmanaged_delete_recursive($test_directory, array('Drupal\simpletest\TestBase', 'filePreDeleteCallback'));
     $messages[] = "- Removed test files directory.";
   }
 
diff --git a/index.php b/index.php
index 38177ab..e24a769 100644
--- a/index.php
+++ b/index.php
@@ -28,7 +28,7 @@ require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
 
 // @todo Figure out how best to handle the Kernel constructor parameters.
-$kernel = new DrupalKernel('prod', FALSE);
+$kernel = new DrupalKernel('prod', FALSE, system_list());
 
 // Create a request object from the HTTPFoundation.
 $request = Request::createFromGlobals();
