Index: lib/MT/Builder.pm
===================================================================
--- lib/MT/Builder.pm	(revision 1184)
+++ lib/MT/Builder.pm	(working copy)
@@ -207,8 +207,9 @@
                 $rec->[3] = '';
             }
         }
-        $rec->[5] = $opt->{parent} || $tmpl;
-        $rec->[6] = $tmpl;
+        # Avoids circular reference between NODE and TOKENS, MT::Template.
+        local($rec->[5]) = $opt->{parent} || $tmpl;
+        local($rec->[6]) = $tmpl;
         push @{ $state->{tokens} }, $rec;
         $pos = pos $text;
     }
@@ -254,8 +255,13 @@
 
 sub _text_block {
     my $text = substr ${ $_[0]->{text} }, $_[1], $_[2] - $_[1];
-    push @{ $_[0]->{tokens} }, bless [ 'TEXT', $text, undef, undef, undef, $_[0]->{tokens}, $_[0]->{tmpl} ], NODE
-        if (defined $text) && ($text ne '');
+    if ((defined $text) && ($text ne '')) {
+        my $rec = bless [ 'TEXT', $text, undef, undef, undef ], NODE;
+        # Avoids circular reference between NODE and TOKENS, MT::Template.
+        local($rec->[5]) = $_[0]->{tokens};
+        local($rec->[6]) = $_[0]->{tmpl};
+        push @{ $_[0]->{tokens} }, $rec;
+    }
 }
 
 sub syntree2str {
@@ -290,7 +296,9 @@
     } else {
         $cond = {};
     }
-    $ctx->stash('builder', $build);
+    # Stores 'builder' as a temporary value in order to avoid circular
+    # reference between MT::Template::Context and MT::Builder.
+    local($ctx->{__stash}{builder}) = $build;
     my $res = '';
     my $ph = $ctx->post_process_handler;
 
Index: lib/MT/Template.pm
===================================================================
--- lib/MT/Template.pm	(revision 1184)
+++ lib/MT/Template.pm	(working copy)
@@ -141,7 +141,8 @@
     return $tmpl->{context} = shift if @_;
     require MT::Template::Context;
     my $ctx = $tmpl->{context} ||= MT::Template::Context->new;
-    $ctx->stash('template', $tmpl);
+    # Avoids circular reference between MT::Template and MT::Template::Context.
+    #$ctx->stash('template', $tmpl);
     return $ctx;
 }
 
