Index: src/Common/Assert.cc
===================================================================
--- src/Common/Assert.cc	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/Assert.cc	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -14,8 +14,7 @@
 //
 
-#include <assert.h>
-#include <cstdarg>										// varargs
-#include <cstdio>										// fprintf
-#include <cstdlib>										// abort
+#include <cstdarg>  // for va_end, va_list, va_start
+#include <cstdio>   // for fprintf, stderr, vfprintf
+#include <cstdlib>  // for abort
 
 extern const char * __progname;							// global name of running executable (argv[0])
Index: src/Common/PassVisitor.h
===================================================================
--- src/Common/PassVisitor.h	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/PassVisitor.h	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -12,4 +12,5 @@
 #include "SynTree/Expression.h"
 #include "SynTree/Constant.h"
+#include "SynTree/TypeSubstitution.h"
 
 #include "PassVisitor.proto.h"
@@ -26,5 +27,5 @@
 //                          stmtsToAddBefore or stmtsToAddAfter respectively.
 // | WithShortCircuiting  - provides the ability to skip visiting child nodes; set visit_children to false in pre{visit,mutate} to skip visiting children
-// | WithScopes           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
+// | WithGuards           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
 //                          will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates.
 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -32,5 +33,4 @@
 class PassVisitor final : public Visitor, public Mutator {
 public:
-	PassVisitor() = default;
 
 	template< typename... Args >
@@ -257,15 +257,4 @@
 
 	void set_visit_children( bool& ref ) { bool_ref * ptr = visit_children_impl(pass, 0); if(ptr) ptr->set( ref ); }
-
-	guard_value_impl init_guard() {
-		guard_value_impl guard;
-		auto at_cleanup = at_cleanup_impl(pass, 0);
-		if( at_cleanup ) {
-			*at_cleanup = [&guard]( cleanup_func_t && func, void* val ) {
-				guard.push( std::move( func ), val );
-			};
-		}
-		return guard;
-	}
 };
 
@@ -283,5 +272,5 @@
 
 public:
-	TypeSubstitution * env;
+	TypeSubstitution * env = nullptr;
 };
 
@@ -295,4 +284,15 @@
 	std::list< Statement* > stmtsToAddAfter;
 };
+
+class WithDeclsToAdd {
+protected:
+	WithDeclsToAdd() = default;
+	~WithDeclsToAdd() = default;
+
+public:
+	std::list< Declaration* > declsToAddBefore;
+	std::list< Declaration* > declsToAddAfter;
+};
+
 class WithShortCircuiting {
 protected:
@@ -304,8 +304,8 @@
 };
 
-class WithScopes {
-protected:
-	WithScopes() = default;
-	~WithScopes() = default;
+class WithGuards {
+protected:
+	WithGuards() = default;
+	~WithGuards() = default;
 
 public:
@@ -318,4 +318,17 @@
 		}, static_cast< void * >( & val ) );
 	}
+
+	template< typename T >
+	void GuardScope( T& val ) {
+		val.beginScope();
+		at_cleanup( []( void * val ) {
+			static_cast< T * >( val )->endScope();
+		}, static_cast< void * >( & val ) );
+	}
+
+	template< typename Func >
+	void GuardAction( Func func ) {
+		at_cleanup( [func](__attribute__((unused)) void *) { func(); }, nullptr );
+	}
 };
 
@@ -323,9 +336,9 @@
 class WithVisitorRef {
 protected:
-	WithVisitorRef() = default;
-	~WithVisitorRef() = default;
-
-public:
-	PassVisitor<pass_type> * const visitor;
+	WithVisitorRef() {}
+	~WithVisitorRef() {}
+
+public:
+	PassVisitor<pass_type> * const visitor = nullptr;
 };
 
Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/PassVisitor.impl.h	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -3,5 +3,5 @@
 #define VISIT_START( node )                     \
 	__attribute__((unused))                   \
-	const auto & guard = init_guard();        \
+	guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
 	bool visit_children = true;               \
 	set_visit_children( visit_children );	\
@@ -15,5 +15,5 @@
 #define MUTATE_START( node )                    \
 	__attribute__((unused))                   \
-	const auto & guard = init_guard();        \
+	guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
 	bool visit_children = true;               \
 	set_visit_children( visit_children );	\
@@ -68,5 +68,5 @@
 	for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
 		// splice in new declarations after previous decl
-		if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }	
+		if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
 
 		if ( i == decls.end() ) break;
@@ -88,5 +88,5 @@
 	for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
 		// splice in new declarations after previous decl
-		if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }	
+		if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
 
 		if ( i == decls.end() ) break;
@@ -104,4 +104,10 @@
 void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
 	SemanticError errors;
+
+	// don't want statements from outer CompoundStmts to be added to this CompoundStmt
+	ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
+	ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
+	ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
+	ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
 
 	StmtList_t* beforeStmts = get_beforeStmts();
@@ -181,5 +187,5 @@
 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
 	return handleStatement( stmt, [this]( Statement * stmt ) {
-		maybeAccept( stmt, *this ); 
+		maybeAccept( stmt, *this );
 		return stmt;
 	});
@@ -212,5 +218,5 @@
 		expr->accept( *this );
 		return expr;
-	});		
+	});
 }
 
@@ -565,4 +571,7 @@
 	VISIT_START( node );
 
+	// maybeAccept( node->get_env(), *this );
+	maybeAccept( node->get_result(), *this );
+
 	for ( auto expr : node->get_args() ) {
 		visitExpression( expr );
@@ -575,4 +584,7 @@
 Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
 	MUTATE_START( node );
+
+	node->set_env( maybeMutate( node->get_env(), *this ) );
+	node->set_result( maybeMutate( node->get_result(), *this ) );
 
 	for ( auto& expr : node->get_args() ) {
Index: src/Common/PassVisitor.proto.h
===================================================================
--- src/Common/PassVisitor.proto.h	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/PassVisitor.proto.h	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -5,8 +5,15 @@
 
 typedef std::function<void( void * )> cleanup_func_t;
+typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t;
 
 class guard_value_impl {
 public:
-	guard_value_impl() = default;
+	guard_value_impl( at_cleanup_t * at_cleanup ) {
+		if( at_cleanup ) {
+			*at_cleanup = [this]( cleanup_func_t && func, void* val ) {
+				push( std::move( func ), val );
+			};
+		}
+	}
 
 	~guard_value_impl() {
@@ -33,5 +40,4 @@
 };
 
-typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t;
 
 class bool_ref {
@@ -56,5 +62,5 @@
 // Deep magic (a.k.a template meta programming) to make the templated visitor work
 // Basically the goal is to make 2 previsit_impl
-// 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of 
+// 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of
 //     'pass.previsit( node )' that compiles will be used for that node for that type
 //     This requires that this option only compile for passes that actually define an appropriate visit.
Index: src/Common/SemanticError.cc
===================================================================
--- src/Common/SemanticError.cc	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/SemanticError.cc	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -14,13 +14,12 @@
 //
 
-#include <iostream>
-#include <list>
-#include <string>
-#include <algorithm>
-#include <iterator>
+#include <cstdio>            // for fileno, stderr
+#include <unistd.h>          // for isatty
+#include <iostream>          // for basic_ostream, operator<<, ostream
+#include <list>              // for list, _List_iterator
+#include <string>            // for string, operator<<, operator+, to_string
 
+#include "Common/utility.h"  // for to_string, CodeLocation (ptr only)
 #include "SemanticError.h"
-
-#include <unistd.h>
 
 inline const std::string& error_str() {
Index: src/Common/SemanticError.h
===================================================================
--- src/Common/SemanticError.h	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/SemanticError.h	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -17,11 +17,10 @@
 #define SEMANTICERROR_H
 
-#include <exception>
-#include <string>
-#include <sstream>
-#include <list>
-#include <iostream>
+#include <exception>  // for exception
+#include <iostream>   // for ostream
+#include <list>       // for list
+#include <string>     // for string
 
-#include "utility.h"
+#include "utility.h"  // for CodeLocation, toString
 
 struct error {
Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision fea3faac1cd99d58dc1dd738883cfb602a81f178)
+++ src/Common/utility.h	(revision b826e6b7674b1614df5016529521f2926b812835)
@@ -305,5 +305,5 @@
 // for ( val : group_iterate( container1, container2, ... ) ) {}
 // syntax to have a for each that iterates multiple containers of the same length
-// TODO: update to use variadic arguments
+// TODO: update to use variadic arguments, perfect forwarding
 
 template< typename T1, typename T2 >
