diff --git a/core/includes/common.inc b/core/includes/common.inc
index f5b84cc..b90c8bc 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -6889,8 +6889,9 @@ function drupal_flush_all_caches() {
   drupal_container()->get('router.builder')->rebuild();
   menu_router_rebuild();
 
-  // Wipe the DIC cache.
+  // Wipe the PHP Storage caches.
   drupal_php_storage('service_container')->deleteAll();
+  drupal_php_storage('twig')->deleteAll();
 
   // Re-initialize the maintenance theme, if the current request attempted to
   // use it. Unlike regular usages of this function, the installer and update
diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php
index 89055cd..bc7ab65 100644
--- a/core/lib/Drupal/Core/Template/TwigEnvironment.php
+++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php
@@ -19,6 +19,10 @@ class TwigEnvironment extends \Twig_Environment {
   protected $cache_object = NULL;
   protected $storage = NULL;
 
+  /**
+   * Constructs a TwigEnvironment object and stores cache and storage
+   * internally.
+   */
   public function __construct(\Twig_LoaderInterface $loader = NULL, $options = array()) {
     // @todo Pass as arguments from the DIC?
     $this->cache_object = cache();
@@ -27,6 +31,27 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr
     parent::__construct($loader, $options);
   }
 
+  /**
+   * Checks if the compiled template needs an update.
+   */
+  public function needsUpdate($cache_filename, $name) {
+     $cid = 'twig:' . $cache_filename;
+     $obj = $this->cache_object->get($cid);
+     $mtime = isset($obj->data) ? $obj->data : FALSE;
+     return $mtime !== FALSE && !$this->isTemplateFresh($name, $mtime);
+  }
+
+  /**
+   * Compile the source and write the compiled template to disk.
+   */
+  public function updateCompiledTemplate($cache_filename, $name) {
+    $source = $this->loader->getSource($name);
+    $compiled_source = $this->compileSource($source, $name);
+    $this->storage->save($cache_filename, $compiled_source);
+    // Save the last modification time
+    $cid = 'twig:' . $cache_filename;
+    $this->cache_object->set($cid, REQUEST_TIME);
+  }
 
   /**
    * Implements Twig_Environment::loadTemplate().
@@ -51,22 +76,17 @@ public function loadTemplate($name, $index = NULL) {
         $compiled_source = $this->compileSource($source, $name);
         eval('?' . '>' . $compiled_source);
       } else {
-        $cid = 'twig:' . $cache_filename;
-        $obj = $this->cache_object->get($cid);
-        $mtime = isset($obj->data) ? $obj->data : FALSE;
 
-        // Check that the compiled template is cached and the storage exists.
-        // If autoreload is on, also check that the template has not been
+        // If autoreload is on, check that the template has not been
         // modified since the last compilation.
-        if (!$mtime || !$this->storage->exists($cache_filename) || ($this->isAutoReload() && !$this->isTemplateFresh($name, $mtime))) {
-          $source = $this->loader->getSource($name);
-          $compiled_source = $this->compileSource($source, $name);
-          $this->storage->save($cache_filename, $compiled_source);
-          // Save the last modification time
-          $this->cache_object->set($cid, REQUEST_TIME);
+        if ($this->isAutoReload() && $this->needsUpdate($cache_filename, $name)) {
+          $this->updateCompiledTemplate($cache_filename, $name);
         }
 
-        $this->storage->load($cache_filename);
+        if (!$this->storage->load($cache_filename)) {
+          $this->updateCompiledTemplate($cache_filename, $name);
+          $this->storage->load($cache_filename);
+        }
       }
     }
 
diff --git a/core/lib/Drupal/Core/Template/TwigFactory.php b/core/lib/Drupal/Core/Template/TwigFactory.php
index d450e79..ef1a40d 100644
--- a/core/lib/Drupal/Core/Template/TwigFactory.php
+++ b/core/lib/Drupal/Core/Template/TwigFactory.php
@@ -58,6 +58,8 @@ public static function get() {
         'strict_variables' => FALSE,
         // @todo Maybe make debug mode dependent on "production mode" setting.
         'debug' => TRUE,
+        // @todo Make auto reload mode dependent on "production mode" setting.
+        'auto_reload' => FALSE,
     ));
 
     // The node visitor is needed to wrap all variables with
diff --git a/core/lib/Drupal/Core/Template/TwigTemplate.php b/core/lib/Drupal/Core/Template/TwigTemplate.php
index fdc5d31..7d7eeca 100644
--- a/core/lib/Drupal/Core/Template/TwigTemplate.php
+++ b/core/lib/Drupal/Core/Template/TwigTemplate.php
@@ -46,8 +46,8 @@
       // We don't want to throw an exception, but issue a warning instead.
       // This is the easiest way to do so.
       // @todo Decide based on prod vs. dev setting
-      $msg = new \Twig_Error(t('@item could not be found in _context.', array('@item' => $item)));
-      drupal_set_message($msg->getMessage(), 'warning');
+      $msg = new \Twig_Error(t('@item could not be found in _context', array('@item' => $item)));
+      trigger_error($msg->getMessage(), E_USER_WARNING);
       return NULL;
     }
 
