diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 898fdf8..4b1dee5 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -22,7 +22,7 @@ public function getFunctions() {
     return array(
       // @todo Remove URL function once http://drupal.org/node/1778610 is resolved.
       'url' => new \Twig_Function_Function('url'),
-      // These functions will receive a TwigReference object, if a render array is detected
+      // These functions will receive a special #twig_reference render array
       'hide' => new TwigReferenceFunction('twig_hide'),
       'render_var' => new TwigReferenceFunction('twig_render_var'),
       'show' => new TwigReferenceFunction('twig_show'),
@@ -37,7 +37,8 @@ public function getFilters() {
 
   public function getNodeVisitors() {
     // The node visitor is needed to wrap all variables with
-    // render_var -> twig_render_var() function.
+    // render_var -> twig_render_var() function and to change the syntax
+    // of reference functions to not use getAttribute or getContext.
     return array(
       new TwigNodeVisitor(),
     );
diff --git a/core/lib/Drupal/Core/Template/TwigNodeExpressionGetAttrReference.php b/core/lib/Drupal/Core/Template/TwigNodeExpressionGetAttrReference.php
new file mode 100644
index 0000000..aa8a086
--- /dev/null
+++ b/core/lib/Drupal/Core/Template/TwigNodeExpressionGetAttrReference.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\Core\Template;
+
+class TwigNodeExpressionGetAttrReference extends \Twig_Node_Expression_GetAttr {
+  public function compile(\Twig_Compiler $compiler) {
+    $compiler->raw('array( "attribute", ');
+    $compiler->subcompile($this->getNode('attribute'));
+
+    if (count($this->getNode('arguments')) || \Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
+            $compiler->raw(', ')->subcompile($this->getNode('arguments'));
+
+            if (\Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
+                $compiler->raw(', ')->repr($this->getAttribute('type'));
+            }
+
+            if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
+                $compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false'));
+            }
+
+            if ($this->getAttribute('ignore_strict_check')) {
+                $compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false'));
+            }
+    }
+    $compiler->raw(')');
+  }
+}
diff --git a/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php
index c66d73f..90a50c0 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php
@@ -20,10 +20,10 @@ class TwigNodeExpressionNameReference extends \Twig_Node_Expression_Name {
    */
   public function compile(\Twig_Compiler $compiler) {
     $name = $this->getAttribute('name');
+    $compiler->raw('array("#twig_reference" => TRUE, "path" => array(');
     $compiler
-    ->raw('$this->getContextReference($context, ')
+    ->raw('array("name", ')
     ->string($name)
     ->raw(')');
   }
-
 }
diff --git a/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReferenceEnd.php b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReferenceEnd.php
new file mode 100644
index 0000000..eb5f84e
--- /dev/null
+++ b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReferenceEnd.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Drupal\Core\Template;
+
+class TwigNodeExpressionNameReferenceEnd extends \Twig_Node_Expression {
+  public function compile(\Twig_Compiler $compiler) {
+    $compiler->raw(')), $context, $this');
+  }
+}
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 710faa0..895633d 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -14,7 +14,7 @@
  * twig_render_var() function so that we can write for example just {{ content }}
  * in templates instead of having to write {{ render_var(content) }}.
  *
- * @see twig_render
+ * @see twig_render_var
  */
 class TwigNodeVisitor implements \Twig_NodeVisitorInterface {
 
@@ -26,27 +26,47 @@ class TwigNodeVisitor implements \Twig_NodeVisitorInterface {
    * @var bool
    */
   protected $isReference = FALSE;
+  protected $isAttributePath = array();
+  protected $dataAttributes = array();
 
   /**
    * Implements Twig_NodeVisitorInterface::enterNode().
    */
   function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
+
+    if ($node->hasAttribute('expression_path')) {
+      array_unshift($this->isAttributePath, $node->getAttribute('expression_path') == 'attribute'?1:0);
+    }
+
+    // Optimization: Do not support nested values.
+    $validPath = count($this->isAttributePath) > 0 ? array_sum($this->isAttributePath) === 0 : TRUE;
+
+   if ($this->isReference && $validPath && !($node instanceof \Twig_Node_Expression_GetAttr || $node instanceof \Twig_Node_Expression_Name || $node instanceof \Twig_Node_Expression_Constant || $node instanceof \Twig_Node_Expression_Array)) {
+     $this->isReference = FALSE;
+   }
+
    if ($node instanceof \Twig_Node_Expression_Function) {
       $name = $node->getAttribute('name');
       $func = $env->getFunction($name);
 
-      // Optimization: Do not support nested functions.
-      if ($this->isReference && $func instanceof \Twig_Function_Function) {
-        $this->isReference = FALSE;
-      }
       if ($func instanceof TwigReferenceFunction) {
         // We need to create a TwigReference
         $this->isReference = TRUE;
+        $node->setAttribute('twig_reference', TRUE);
+        array_unshift($this->dataAttributes, array());
       }
     }
     if ($node instanceof \Twig_Node_Print) {
        // Our injected render_var needs arguments passed by reference -- in case of render array
       $this->isReference = TRUE;
+      $node->setAttribute('twig_reference', TRUE);
+      array_unshift($this->dataAttributes, array());
+    }
+    if ($node instanceof \Twig_Node_Expression_GetAttr) {
+        $nodeI = $node->getNode('node');
+        $nodeI->setAttribute('expression_path', 'node');
+        $attribute = $node->getNode('attribute');
+        $attribute->setAttribute('expression_path', 'attribute');
     }
 
     return $node;
@@ -61,6 +81,16 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
    * @see twig_render
    */
   function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
+
+    if ($this->isReference && $node->hasAttribute('twig_reference')) {
+      $nodes = array_shift($this->dataAttributes);
+      if (count($nodes) > 0) {
+        $nodes[] = new TwigNodeExpressionNameReferenceEnd();
+        $node->setNode('arguments', new \Twig_Node($nodes));
+      }
+      $this->isReference = FALSE;
+    }
+
     if ($node instanceof \Twig_Node_Print) {
       $this->isReference = FALSE;
 
@@ -70,18 +100,36 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
         $node->getLine()
       );
     }
+    $validPath = count($this->isAttributePath) > 0 ? array_sum($this->isAttributePath) === 0 : TRUE;
 
-    if ($this->isReference) {
+    if ($this->isReference && $validPath) {
       if ($node instanceof \Twig_Node_Expression_Name) {
         $name = $node->getAttribute('name');
-        return new TwigNodeExpressionNameReference($name, $node->getLine());
+        $newNode = new TwigNodeExpressionNameReference($name, $node->getLine());
+        array_push($this->dataAttributes[0], $newNode);
+        return $node;
       }
-      elseif ($node instanceof \Twig_Function_Function) {
-        // Do something!
-        $this->isReference = FALSE;
+      elseif ($node instanceof \Twig_Node_Expression_GetAttr) {
+        $nodeI = $node->getNode('node');
+        $attribute = $node->getNode('attribute');
+        $arguments = $node->getNode('arguments');
+        $type = $node->getAttribute('type');
+
+        $newNode = new TwigNodeExpressionGetAttrReference($nodeI, $attribute, $arguments, $type, $node->getLine());
+        array_push($this->dataAttributes[0], $newNode);
+        return $node;
       }
     }
 
+   if ($node instanceof \Twig_Function_Function) {
+     // Do something!
+     $this->isReference = FALSE;
+   }
+
+    if ($node->hasAttribute('expression_path')) {
+      array_shift($this->isAttributePath);
+    }
+
     return $node;
   }
 
diff --git a/core/lib/Drupal/Core/Template/TwigTemplate.php b/core/lib/Drupal/Core/Template/TwigTemplate.php
index cb2d91d..ab7c733 100644
--- a/core/lib/Drupal/Core/Template/TwigTemplate.php
+++ b/core/lib/Drupal/Core/Template/TwigTemplate.php
@@ -87,4 +87,23 @@
 
     return $ref;
   }
+
+  public function &unwrapReference(&$context, $val) {
+    $path = $val['path'];
+    $return = &$context;
+
+    foreach ($val['path'] as $p) {
+      $name = $p[1];
+      if ($p[0] == 'name' && $name == '_context') {
+        continue;
+      }
+      if (is_array($return) && isset($return[$name])) {
+        $return = &$return[$name];
+      } else {
+        $return = $this->getAttribute($return, $name, isset($p[2])?$p[2]:array(), isset($p[3])?$p[3]:'any'); // @todo Make tests work as well ...
+      }
+    }
+
+    return $return;
+  }
 }
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index b541cdc..a0a2583 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -95,9 +95,9 @@ function twig_render_template($template_file, $variables) {
  * @see render
  * @see TwigNodeVisitor
  */
-function twig_render_var($arg) {
-  if ($arg instanceof TwigReference) {
-    $arg = &$arg->getReference();
+function twig_render_var($arg, &$context = array(), $template = NULL) {
+  if (isset($template) && !empty($context) && isset($arg['#twig_reference']) && $arg['#twig_reference'] === TRUE) {
+      $arg = &$template->unwrapReference($context, $arg);
   }
 
   // Check for numeric zero.
@@ -135,12 +135,12 @@ function twig_render_var($arg) {
  *
  * @see hide
  */
-function twig_hide($element) {
-  if ($element instanceof TwigReference) {
-    $element = &$element->getReference();
-    hide($element);
-  }
-  // @todo Add warning in else case
+function twig_hide($val, &$context = array(), $template = NULL) {
+    // Unwrap reference if twig_reference key is set
+    if (isset($template) && !empty($context) && isset($val['#twig_reference']) && $val['#twig_reference'] === TRUE) {
+      $val = &$template->unwrapReference($context, $val);
+    }
+    hide($val);
 }
 
 /**
@@ -148,10 +148,9 @@ function twig_hide($element) {
  *
  * @see show
  */
-function twig_show($element) {
-  if ($element instanceof TwigReference) {
-    $element = &$element->getReference();
-    show($element);
+function twig_show($val, &$context = array(), $template = NULL) {
+  if (isset($template) && !empty($context) && isset($val['#twig_reference']) && $val['#twig_reference'] === TRUE) {
+      $val = &$template->unwrapReference($context, $val);
   }
-  // @todo Add warning in else case
+  show($val);
 }
