diff --git a/includes/theme.inc b/includes/theme.inc
index 9bd7062..4d162b6 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -934,7 +934,7 @@ function theme($hook, $variables = array()) {
     if (isset($info['path'])) {
       $template_file = $info['path'] . '/' . $template_file;
     }
-    $output = $render_function($template_file, $variables);
+    $output = $render_function($template_file, $variables, $info);
   }
 
   // restore path_to_theme()
@@ -1237,17 +1237,31 @@ function theme_get_setting($setting_name, $theme = NULL) {
  *   The filename of the template to render.
  * @param $variables
  *   A keyed array of variables that will appear in the output.
+ * @param $info
+ *   The template info.
  *
  * @return
  *   The output generated by the template.
  */
-function theme_render_template($template_file, $variables) {
+function theme_render_template($template_file, $variables, $info = array()) {
+  $render_stack = &drupal_static(__FUNCTION__, array());
+  if (isset($info['render element'])) {
+    $render_stack[] = &$variables[$info['render element']];
+  }
   extract($variables, EXTR_SKIP);               // Extract the variables to a local namespace
   ob_start();                                   // Start output buffering
   include DRUPAL_ROOT . '/' . $template_file;   // Include the template file
+  if (isset($info['render element'])) {
+    array_pop($render_stack);
+  }
   return ob_get_clean();                        // End buffering and return its contents
 }
 
+function write($key) {
+  $render_stack = &drupal_static('theme_render_template', array());
+  print render($render_stack[count($render_stack) - 1][$key]);
+}
+
 /**
  * Enable a given list of themes.
  *
diff --git a/themes/bartik/templates/page.tpl.php b/themes/bartik/templates/page.tpl.php
index 7b0f990..c608aa8 100644
--- a/themes/bartik/templates/page.tpl.php
+++ b/themes/bartik/templates/page.tpl.php
@@ -120,7 +120,7 @@
       </div> <!-- /#name-and-slogan -->
     <?php endif; ?>
 
-    <?php print render($page['header']); ?>
+    <?php write('header'); ?>
 
     <?php if ($main_menu): ?>
       <div id="main-menu" class="navigation">
@@ -166,7 +166,7 @@
 
   <?php if ($page['featured']): ?>
     <div id="featured"><div class="section clearfix">
-      <?php print render($page['featured']); ?>
+      <?php write('featured'); ?>
     </div></div> <!-- /.section, /#featured -->
   <?php endif; ?>
 
@@ -178,12 +178,12 @@
 
     <?php if ($page['sidebar_first']): ?>
       <div id="sidebar-first" class="column sidebar"><div class="section">
-        <?php print render($page['sidebar_first']); ?>
+        <?php write('sidebar_first'); ?>
       </div></div> <!-- /.section, /#sidebar-first -->
     <?php endif; ?>
 
     <div id="content" class="column"><div class="section">
-      <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
+      <?php if ($page['highlighted']): ?><div id="highlighted"><?php write('highlighted'); ?></div><?php endif; ?>
       <a id="main-content"></a>
       <?php print render($title_prefix); ?>
       <?php if ($title): ?>
@@ -197,20 +197,20 @@
           <?php print render($tabs); ?>
         </div>
       <?php endif; ?>
-      <?php print render($page['help']); ?>
+      <?php write('help'); ?>
       <?php if ($action_links): ?>
         <ul class="action-links">
           <?php print render($action_links); ?>
         </ul>
       <?php endif; ?>
-      <?php print render($page['content']); ?>
+      <?php write('content'); ?>
       <?php print $feed_icons; ?>
 
     </div></div> <!-- /.section, /#content -->
 
     <?php if ($page['sidebar_second']): ?>
       <div id="sidebar-second" class="column sidebar"><div class="section">
-        <?php print render($page['sidebar_second']); ?>
+        <?php write('sidebar_second'); ?>
       </div></div> <!-- /.section, /#sidebar-second -->
     <?php endif; ?>
 
@@ -218,9 +218,9 @@
 
   <?php if ($page['triptych_first'] || $page['triptych_middle'] || $page['triptych_last']): ?>
     <div id="triptych-wrapper"><div id="triptych" class="clearfix">
-      <?php print render($page['triptych_first']); ?>
-      <?php print render($page['triptych_middle']); ?>
-      <?php print render($page['triptych_last']); ?>
+      <?php write('triptych_first'); ?>
+      <?php write('triptych_middle'); ?>
+      <?php write('triptych_last'); ?>
     </div></div> <!-- /#triptych, /#triptych-wrapper -->
   <?php endif; ?>
 
@@ -228,16 +228,16 @@
 
     <?php if ($page['footer_firstcolumn'] || $page['footer_secondcolumn'] || $page['footer_thirdcolumn'] || $page['footer_fourthcolumn']): ?>
       <div id="footer-columns" class="clearfix">
-        <?php print render($page['footer_firstcolumn']); ?>
-        <?php print render($page['footer_secondcolumn']); ?>
-        <?php print render($page['footer_thirdcolumn']); ?>
-        <?php print render($page['footer_fourthcolumn']); ?>
+        <?php write('footer_firstcolumn'); ?>
+        <?php write('footer_secondcolumn'); ?>
+        <?php write('footer_thirdcolumn'); ?>
+        <?php write('footer_fourthcolumn'); ?>
       </div> <!-- /#footer-columns -->
     <?php endif; ?>
 
     <?php if ($page['footer']): ?>
       <div id="footer" class="clearfix">
-        <?php print render($page['footer']); ?>
+        <?php write('footer'); ?>
       </div> <!-- /#footer -->
     <?php endif; ?>
 
