diff --git a/doc/build/content/documentation.html b/doc/build/content/documentation.html
index 71421c70e5739b2b45b8db9bbddcef052049c79a..250c51123a86670ecc11d1e7e30700d7c2f84094 100644
--- a/doc/build/content/documentation.html
+++ b/doc/build/content/documentation.html
@@ -19,7 +19,6 @@ ${tocns.toc(toc=toc, extension=extension, paged=False)}
         ${nav.pagenav(item=item, paged=False)}
     </div>
 
-    ${self.get_namespace(file + '.html').body(paged=False)}
-
+    ${self.get_namespace(file + '.html').body(paged=False, toc=toc, extension=extension)}
 % endfor
 
diff --git a/lib/mako/codegen.py b/lib/mako/codegen.py
index 81272ea9e9ac91ecc5984b54b3c78534f854a116..072ce54fccc785b7ab292a5df03579477fca6e07 100644
--- a/lib/mako/codegen.py
+++ b/lib/mako/codegen.py
@@ -46,7 +46,7 @@ class _GenerateRenderMethod(object):
             pagetag = None
         else:
             (pagetag, defs) = self.write_toplevel()
-            name = "render"
+            name = "render_body"
             args = None
             buffered = filtered = False
             self.compiler.pagetag = pagetag
@@ -172,10 +172,10 @@ class _GenerateRenderMethod(object):
         self.printer.writelines(
             "def _mako_get_namespace(context, name):",
             "try:",
-            "return context.namespaces[(render, name)]",
+            "return context.namespaces[(__name__, name)]",
             "except KeyError:",
             "_mako_generate_namespaces(context)",
-            "return context.namespaces[(render, name)]",
+            "return context.namespaces[(__name__, name)]",
             None,None
             )
         self.printer.writeline("def _mako_generate_namespaces(context):")
@@ -202,7 +202,7 @@ class _GenerateRenderMethod(object):
             self.printer.writeline("ns = runtime.Namespace(%s, context._clean_inheritance_tokens(), templateuri=%s, callables=%s, calling_uri=_template_uri)" % (repr(node.name), node.parsed_attributes.get('file', 'None'), callable_name))
             if eval(node.attributes.get('inheritable', "False")):
                 self.printer.writeline("context['self'].%s = ns" % (node.name))
-            self.printer.writeline("context.namespaces[(render, %s)] = ns" % repr(node.name))
+            self.printer.writeline("context.namespaces[(__name__, %s)] = ns" % repr(node.name))
             self.printer.write("\n")
         if not len(namespaces):
             self.printer.writeline("pass")
diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py
index 4f1792c20fdf94cfa2ca9283ea4bacf4c91b9e52..42fb0365ec545d701cbb9f1881822c66d95abc61 100644
--- a/lib/mako/runtime.py
+++ b/lib/mako/runtime.py
@@ -85,9 +85,11 @@ class Namespace(object):
         self._module = module
         if templateuri is not None:
             self.template = _lookup_template(context, templateuri, calling_uri)
+            self._templateuri = self.template.module._template_uri
         else:
             self.template = template
-        self._templateuri = templateuri
+            if self.template is not None:
+                self._templateuri = self.template.module._template_uri
         self.context = context
         self.inherits = inherits
         if callables is not None:
@@ -113,6 +115,9 @@ class Namespace(object):
             self.context.namespaces[key] = ns
             return ns
     
+    def get_template(self, uri):
+        return _lookup_template(self.context, uri, self._templateuri)
+        
     def get_cached(self, key, **kwargs):
         if self.template:
             if self.template.cache_dir:
@@ -155,15 +160,11 @@ class Namespace(object):
             except KeyError:
                 pass
         if self.template is not None:
-            if key == 'body':
-                callable_ = self.template.module.render
-            else:
-                try:
-                    callable_ = self.template.get_def(key).callable_
-                except AttributeError:
-                    callable_ = None
-            if callable_ is not None:
+            try:
+                callable_ = self.template.get_def(key).callable_
                 return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
+            except AttributeError:
+                pass
         if self._module is not None:
             try:
                 callable_ = getattr(self._module, key)
@@ -252,14 +253,16 @@ def _render(template, callable_, args, data, as_unicode=False):
     _render_context(template, callable_, context, *args, **kwargs)
     return context.pop_buffer().getvalue()
 
-def _render_context(template, callable_, context, *args, **kwargs):
+def _render_context(tmpl, callable_, context, *args, **kwargs):
+    import mako.template as template
     # create polymorphic 'self' namespace for this template with possibly updated context
-    (inherit, lclcontext) = _populate_self_namespace(context, template)
-    if callable_.__name__ == 'render':
+    if not isinstance(tmpl, template.DefTemplate):
         # if main render method, call from the base of the inheritance stack
+        (inherit, lclcontext) = _populate_self_namespace(context, tmpl)
         _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
     else:
         # otherwise, call the actual rendering method specified
+        (inherit, lclcontext) = _populate_self_namespace(context, tmpl.parent)
         _exec_template(callable_, context, args=args, kwargs=kwargs)
         
 def _exec_template(callable_, context, args=None, kwargs=None):
diff --git a/lib/mako/template.py b/lib/mako/template.py
index 59717420ba9c6331dee6e3beb08b53653d5ffa1d..9dd895ccfb05d6a795e3512c8aa54ee624cdeb6a 100644
--- a/lib/mako/template.py
+++ b/lib/mako/template.py
@@ -72,7 +72,7 @@ class Template(object):
 
         self.module = module
         self.filename = filename
-        self.callable_ = self.module.render
+        self.callable_ = self.module.render_body
         self.format_exceptions = format_exceptions
         self.error_handler = error_handler
         self.lookup = lookup