Index: src/SymTab/Autogen.cc
===================================================================
--- src/SymTab/Autogen.cc	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/Autogen.cc	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -16,5 +16,4 @@
 #include "Autogen.h"
 
-#include <cstddef>                 // for NULL
 #include <algorithm>               // for count_if
 #include <cassert>                 // for strict_dynamic_cast, assert, assertf
@@ -27,8 +26,10 @@
 #include "AddVisit.h"              // for addVisit
 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign
+#include "Common/PassVisitor.h"    // for PassVisitor
 #include "Common/ScopedMap.h"      // for ScopedMap<>::const_iterator, Scope...
 #include "Common/utility.h"        // for cloneAll, operator+
-#include "GenPoly/DeclMutator.h"   // for DeclMutator
 #include "GenPoly/ScopedSet.h"     // for ScopedSet, ScopedSet<>::iterator
+#include "InitTweak/GenInit.h"     // for fixReturnStatements
+#include "ResolvExpr/Resolver.h"   // for resolveDecl
 #include "SymTab/Mangler.h"        // for Mangler
 #include "SynTree/Attribute.h"     // For Attribute
@@ -53,35 +54,21 @@
 	};
 
-	class AutogenerateRoutines final : public Visitor {
-	    template< typename Visitor >
-	    friend void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor );
-	    template< typename Visitor >
-	    friend void addVisitStatementList( std::list< Statement* > &stmts, Visitor &visitor );
-	  public:
-		std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
-
-		typedef Visitor Parent;
-		using Parent::visit;
-
+	struct AutogenerateRoutines final : public WithDeclsToAdd, public WithVisitorRef<AutogenerateRoutines>, public WithGuards, public WithShortCircuiting {
 		AutogenerateRoutines();
 
-		virtual void visit( EnumDecl *enumDecl );
-		virtual void visit( StructDecl *structDecl );
-		virtual void visit( UnionDecl *structDecl );
-		virtual void visit( TypeDecl *typeDecl );
-		virtual void visit( TraitDecl *ctxDecl );
-		virtual void visit( FunctionDecl *functionDecl );
-
-		virtual void visit( FunctionType *ftype );
-		virtual void visit( PointerType *ftype );
-
-		virtual void visit( CompoundStmt *compoundStmt );
-		virtual void visit( SwitchStmt *switchStmt );
+		void previsit( EnumDecl * enumDecl );
+		void previsit( StructDecl * structDecl );
+		void previsit( UnionDecl * structDecl );
+		void previsit( TypeDecl * typeDecl );
+		void previsit( TraitDecl * traitDecl );
+		void previsit( FunctionDecl * functionDecl );
+
+		void previsit( FunctionType * ftype );
+		void previsit( PointerType * ptype );
+
+		void previsit( CompoundStmt * compoundStmt );
 
 	  private:
-		template< typename StmtClass > void visitStatement( StmtClass *stmt );
-
-		std::list< Declaration * > declsToAdd, declsToAddAfter;
-		std::set< std::string > structsDone;
+		GenPoly::ScopedSet< std::string > structsDone;
 		unsigned int functionNesting = 0;     // current level of nested functions
 		/// Note: the following maps could be ScopedSets, but it should be easier to work
@@ -93,16 +80,10 @@
 
 	/// generates routines for tuple types.
-	/// Doesn't really need to be a mutator, but it's easier to reuse DeclMutator than it is to use AddVisit
-	/// or anything we currently have that supports adding new declarations for visitors
-	class AutogenTupleRoutines : public GenPoly::DeclMutator {
-	  public:
-		typedef GenPoly::DeclMutator Parent;
-		using Parent::mutate;
-
-		virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
-
-		virtual Type * mutate( TupleType *tupleType );
-
-		virtual CompoundStmt * mutate( CompoundStmt *compoundStmt );
+	struct AutogenTupleRoutines : public WithDeclsToAdd, public WithVisitorRef<AutogenTupleRoutines>, public WithGuards, public WithShortCircuiting {
+		void previsit( FunctionDecl *functionDecl );
+
+		void postvisit( TupleType *tupleType );
+
+		void previsit( CompoundStmt *compoundStmt );
 
 	  private:
@@ -112,14 +93,14 @@
 
 	void autogenerateRoutines( std::list< Declaration * > &translationUnit ) {
-		AutogenerateRoutines generator;
-		acceptAndAdd( translationUnit, generator );
+		PassVisitor<AutogenerateRoutines> generator;
+		acceptAll( translationUnit, generator );
 
 		// needs to be done separately because AutogenerateRoutines skips types that appear as function arguments, etc.
 		// AutogenTupleRoutines tupleGenerator;
-		// tupleGenerator.mutateDeclarationList( translationUnit );
+		// acceptAll( translationUnit, tupleGenerator );
 	}
 
 	bool isUnnamedBitfield( ObjectDecl * obj ) {
-		return obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL;
+		return obj != nullptr && obj->get_name() == "" && obj->get_bitfieldWidth() != nullptr;
 	}
 
@@ -128,5 +109,5 @@
 		FunctionDecl * decl = functionDecl->clone();
 		delete decl->get_statements();
-		decl->set_statements( NULL );
+		decl->set_statements( nullptr );
 		declsToAdd.push_back( decl );
 		decl->fixUniqueId();
@@ -339,5 +320,5 @@
 				assert( ! func->get_functionType()->get_parameters().empty() );
 				ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().front() );
-				ObjectDecl * srcParam = NULL;
+				ObjectDecl * srcParam = nullptr;
 				if ( func->get_functionType()->get_parameters().size() == 2 ) {
 					srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().back() );
@@ -346,5 +327,5 @@
 				assert( dstParam );
 
-				Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL;
+				Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : nullptr;
 				makeStructMemberOp( dstParam, srcselect, field, func, forward );
 			} // if
@@ -385,5 +366,5 @@
 				} else {
 					// no matching parameter, initialize field with default ctor
-					makeStructMemberOp( dstParam, NULL, field, func );
+					makeStructMemberOp( dstParam, nullptr, field, func );
 				}
 			}
@@ -401,11 +382,10 @@
 	void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) {
 		// Builtins do not use autogeneration.
-		if ( aggregateDecl->get_linkage() == LinkageSpec::BuiltinCFA ||
-			 aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) {
+		if ( LinkageSpec::isBuiltin( aggregateDecl->get_linkage() ) ) {
 			return;
 		}
 
 		// Make function polymorphic in same parameters as generic struct, if applicable
-		const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
+		const std::list< TypeDecl * > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
 
 		// generate each of the functions based on the supplied FuncData objects
@@ -572,11 +552,12 @@
 		// the order here determines the order that these functions are generated.
 		// assignment should come last since it uses copy constructor in return.
-		data.push_back( FuncData( "?{}", genDefaultType, constructable ) );
-		data.push_back( FuncData( "?{}", genCopyType, copyable ) );
-		data.push_back( FuncData( "^?{}", genDefaultType, destructable ) );
-		data.push_back( FuncData( "?=?", genAssignType, assignable ) );
-	}
-
-	void AutogenerateRoutines::visit( EnumDecl *enumDecl ) {
+		data.emplace_back( "?{}", genDefaultType, constructable );
+		data.emplace_back( "?{}", genCopyType, copyable );
+		data.emplace_back( "^?{}", genDefaultType, destructable );
+		data.emplace_back( "?=?", genAssignType, assignable );
+	}
+
+	void AutogenerateRoutines::previsit( EnumDecl * enumDecl ) {
+		visit_children = false;
 		if ( ! enumDecl->get_members().empty() ) {
 			EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
@@ -586,19 +567,21 @@
 	}
 
-	void AutogenerateRoutines::visit( StructDecl *structDecl ) {
-		if ( structDecl->has_body() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
-			StructInstType structInst( Type::Qualifiers(), structDecl->get_name() );
-			for ( TypeDecl * typeDecl : structDecl->get_parameters() ) {
+	void AutogenerateRoutines::previsit( StructDecl * structDecl ) {
+		visit_children = false;
+		if ( structDecl->has_body() && structsDone.find( structDecl->name ) == structsDone.end() ) {
+			StructInstType structInst( Type::Qualifiers(), structDecl->name );
+			for ( TypeDecl * typeDecl : structDecl->parameters ) {
 				// need to visit assertions so that they are added to the appropriate maps
-				acceptAll( typeDecl->get_assertions(), *this );
-				structInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
+				acceptAll( typeDecl->assertions, *visitor );
+				structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
 			}
 			structInst.set_baseStruct( structDecl );
 			makeStructFunctions( structDecl, &structInst, functionNesting, declsToAddAfter, data );
-			structsDone.insert( structDecl->get_name() );
+			structsDone.insert( structDecl->name );
 		} // if
 	}
 
-	void AutogenerateRoutines::visit( UnionDecl *unionDecl ) {
+	void AutogenerateRoutines::previsit( UnionDecl * unionDecl ) {
+		visit_children = false;
 		if ( ! unionDecl->get_members().empty() ) {
 			UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
@@ -619,5 +602,6 @@
 
 	// generate ctor/dtors/assign for typedecls, e.g., otype T = int *;
-	void AutogenerateRoutines::visit( TypeDecl *typeDecl ) {
+	void AutogenerateRoutines::previsit( TypeDecl * typeDecl ) {
+		visit_children = false;
 		if ( ! typeDecl->base ) return;
 
@@ -664,31 +648,21 @@
 	}
 
-	void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
-		for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
-			statements.insert( i, new DeclStmt( noLabels, *decl ) );
-		} // for
-		declsToAdd.clear();
-	}
-
-	void AutogenerateRoutines::visit( FunctionType *) {
+	void AutogenerateRoutines::previsit( FunctionType *) {
 		// ensure that we don't add assignment ops for types defined as part of the function
-	}
-
-	void AutogenerateRoutines::visit( PointerType *) {
+		visit_children = false;
+	}
+
+	void AutogenerateRoutines::previsit( PointerType *) {
 		// ensure that we don't add assignment ops for types defined as part of the pointer
-	}
-
-	void AutogenerateRoutines::visit( TraitDecl *) {
+		visit_children = false;
+	}
+
+	void AutogenerateRoutines::previsit( TraitDecl * ) {
 		// ensure that we don't add assignment ops for types defined as part of the trait
-	}
-
-	template< typename StmtClass >
-	inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) {
-		std::set< std::string > oldStructs = structsDone;
-		addVisit( stmt, *this );
-		structsDone = oldStructs;
-	}
-
-	void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) {
+		visit_children = false;
+	}
+
+	void AutogenerateRoutines::previsit( FunctionDecl * functionDecl ) {
+		visit_children = false;
 		// record the existence of this function as appropriate
 		insert( functionDecl, constructable, InitTweak::isDefaultConstructor );
@@ -697,24 +671,16 @@
 		insert( functionDecl, destructable, InitTweak::isDestructor );
 
-		maybeAccept( functionDecl->get_functionType(), *this );
+		maybeAccept( functionDecl->type, *visitor );
 		functionNesting += 1;
-		maybeAccept( functionDecl->get_statements(), *this );
+		maybeAccept( functionDecl->statements, *visitor );
 		functionNesting -= 1;
 	}
 
-	void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) {
-		constructable.beginScope();
-		assignable.beginScope();
-		copyable.beginScope();
-		destructable.beginScope();
-		visitStatement( compoundStmt );
-		constructable.endScope();
-		assignable.endScope();
-		copyable.endScope();
-		destructable.endScope();
-	}
-
-	void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) {
-		visitStatement( switchStmt );
+	void AutogenerateRoutines::previsit( CompoundStmt * ) {
+		GuardScope( constructable );
+		GuardScope( assignable );
+		GuardScope( copyable );
+		GuardScope( destructable );
+		GuardScope( structsDone );
 	}
 
@@ -734,8 +700,7 @@
 	}
 
-	Type * AutogenTupleRoutines::mutate( TupleType * tupleType ) {
-		tupleType = strict_dynamic_cast< TupleType * >( Parent::mutate( tupleType ) );
+	void AutogenTupleRoutines::postvisit( TupleType * tupleType ) {
 		std::string mangleName = SymTab::Mangler::mangleType( tupleType );
-		if ( seenTuples.find( mangleName ) != seenTuples.end() ) return tupleType;
+		if ( seenTuples.find( mangleName ) != seenTuples.end() ) return;
 		seenTuples.insert( mangleName );
 
@@ -785,25 +750,20 @@
 		makeTupleFunctionBody( dtorDecl );
 
-		addDeclaration( ctorDecl );
-		addDeclaration( copyCtorDecl );
-		addDeclaration( dtorDecl );
-		addDeclaration( assignDecl ); // assignment should come last since it uses copy constructor in return
-
-		return tupleType;
-	}
-
-	DeclarationWithType * AutogenTupleRoutines::mutate( FunctionDecl *functionDecl ) {
-		functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
+		declsToAddBefore.push_back( ctorDecl );
+		declsToAddBefore.push_back( copyCtorDecl );
+		declsToAddBefore.push_back( dtorDecl );
+		declsToAddBefore.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return
+	}
+
+	void AutogenTupleRoutines::previsit( FunctionDecl *functionDecl ) {
+		visit_children = false;
+		maybeAccept( functionDecl->type, *visitor );
 		functionNesting += 1;
-		functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
+		maybeAccept( functionDecl->statements, *visitor );
 		functionNesting -= 1;
-		return functionDecl;
-	}
-
-	CompoundStmt * AutogenTupleRoutines::mutate( CompoundStmt *compoundStmt ) {
-		seenTuples.beginScope();
-		compoundStmt = strict_dynamic_cast< CompoundStmt * >( Parent::mutate( compoundStmt ) );
-		seenTuples.endScope();
-		return compoundStmt;
+	}
+
+	void AutogenTupleRoutines::previsit( CompoundStmt * ) {
+		GuardScope( seenTuples );
 	}
 } // SymTab
Index: src/SymTab/FixFunction.cc
===================================================================
--- src/SymTab/FixFunction.cc	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/FixFunction.cc	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -27,8 +27,8 @@
 
 	DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
+		// can't delete function type because it may contain assertions, so transfer ownership to new object
 		ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
 		functionDecl->get_attributes().clear();
-		// can't delete function type because it may contain assertions, but can't transfer ownership without a clone since set_type checks for nullptr
-		functionDecl->set_type( functionDecl->get_type()->clone() );
+		functionDecl->type = nullptr;
 		delete functionDecl;
 		return pointer;
Index: src/SymTab/Indexer.cc
===================================================================
--- src/SymTab/Indexer.cc	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/Indexer.cc	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -40,17 +40,4 @@
 
 namespace SymTab {
-	struct NewScope {
-		NewScope( SymTab::Indexer & indexer ) : indexer( indexer ) { indexer.enterScope(); }
-		~NewScope() { indexer.leaveScope(); }
-		SymTab::Indexer & indexer;
-	};
-
-	template< typename TreeType, typename VisitorType >
-	inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
-		visitor.enterScope();
-		maybeAccept( tree, visitor );
-		visitor.leaveScope();
-	}
-
 	typedef std::unordered_map< std::string, DeclarationWithType* > MangleTable;
 	typedef std::unordered_map< std::string, MangleTable > IdTable;
@@ -198,9 +185,9 @@
 	}
 
-	Indexer::Indexer( bool _doDebug ) : tables( 0 ), scope( 0 ), doDebug( _doDebug ) {}
-
-	Indexer::Indexer( const Indexer &that ) : tables( newRef( that.tables ) ), scope( that.scope ), doDebug( that.doDebug ) {}
-
-	Indexer::Indexer( Indexer &&that ) : tables( that.tables ), scope( that.scope ), doDebug( that.doDebug ) {
+	Indexer::Indexer() : tables( 0 ), scope( 0 ) {}
+
+	Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {}
+
+	Indexer::Indexer( Indexer &&that ) : doDebug( that.doDebug ), tables( that.tables ), scope( that.scope ) {
 		that.tables = 0;
 	}
Index: src/SymTab/Indexer.h
===================================================================
--- src/SymTab/Indexer.h	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/Indexer.h	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -26,5 +26,5 @@
 	class Indexer {
 	  public:
-		explicit Indexer( bool useDebug = false );
+		explicit Indexer();
 
 		Indexer( const Indexer &that );
@@ -76,4 +76,5 @@
 		void addTrait( TraitDecl *decl );
 
+		bool doDebug = false; ///< Display debugging trace?
 	  private:
 		struct Impl;
@@ -81,5 +82,4 @@
 		Impl *tables;         ///< Copy-on-write instance of table data structure
 		unsigned long scope;  ///< Scope index of this pointer
-		bool doDebug;         ///< Display debugging trace?
 
 		/// Takes a new ref to a table (returns null if null)
Index: src/SymTab/Mangler.cc
===================================================================
--- src/SymTab/Mangler.cc	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/Mangler.cc	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -31,5 +31,5 @@
 
 namespace SymTab {
-	std::string Mangler::mangleType( Type *ty ) {
+	std::string Mangler::mangleType( Type * ty ) {
 		Mangler mangler( false, true );
 		maybeAccept( ty, mangler );
@@ -48,5 +48,5 @@
 	}
 
-	void Mangler::mangleDecl( DeclarationWithType *declaration ) {
+	void Mangler::mangleDecl( DeclarationWithType * declaration ) {
 		bool wasTopLevel = isTopLevel;
 		if ( isTopLevel ) {
@@ -79,18 +79,18 @@
 	}
 
-	void Mangler::visit( ObjectDecl *declaration ) {
+	void Mangler::visit( ObjectDecl * declaration ) {
 		mangleDecl( declaration );
 	}
 
-	void Mangler::visit( FunctionDecl *declaration ) {
+	void Mangler::visit( FunctionDecl * declaration ) {
 		mangleDecl( declaration );
 	}
 
-	void Mangler::visit( VoidType *voidType ) {
+	void Mangler::visit( VoidType * voidType ) {
 		printQualifiers( voidType );
 		mangleName << "v";
 	}
 
-	void Mangler::visit( BasicType *basicType ) {
+	void Mangler::visit( BasicType * basicType ) {
 		static const char *btLetter[] = {
 			"b",	// Bool
@@ -123,5 +123,5 @@
 	}
 
-	void Mangler::visit( PointerType *pointerType ) {
+	void Mangler::visit( PointerType * pointerType ) {
 		printQualifiers( pointerType );
 		mangleName << "P";
@@ -129,5 +129,5 @@
 	}
 
-	void Mangler::visit( ArrayType *arrayType ) {
+	void Mangler::visit( ArrayType * arrayType ) {
 		// TODO: encode dimension
 		printQualifiers( arrayType );
@@ -136,5 +136,5 @@
 	}
 
-	void Mangler::visit( ReferenceType *refType ) {
+	void Mangler::visit( ReferenceType * refType ) {
 		printQualifiers( refType );
 		mangleName << "R";
@@ -151,5 +151,5 @@
 	}
 
-	void Mangler::visit( FunctionType *functionType ) {
+	void Mangler::visit( FunctionType * functionType ) {
 		printQualifiers( functionType );
 		mangleName << "F";
@@ -162,5 +162,5 @@
 	}
 
-	void Mangler::mangleRef( ReferenceToType *refType, std::string prefix ) {
+	void Mangler::mangleRef( ReferenceToType * refType, std::string prefix ) {
 		printQualifiers( refType );
 
@@ -168,5 +168,5 @@
 	}
 
-	void Mangler::mangleGenericRef( ReferenceToType *refType, std::string prefix ) {
+	void Mangler::mangleGenericRef( ReferenceToType * refType, std::string prefix ) {
 		printQualifiers( refType );
 
@@ -191,19 +191,19 @@
 	}
 
-	void Mangler::visit( StructInstType *aggregateUseType ) {
+	void Mangler::visit( StructInstType * aggregateUseType ) {
 		if ( typeMode ) mangleGenericRef( aggregateUseType, "s" );
 		else mangleRef( aggregateUseType, "s" );
 	}
 
-	void Mangler::visit( UnionInstType *aggregateUseType ) {
+	void Mangler::visit( UnionInstType * aggregateUseType ) {
 		if ( typeMode ) mangleGenericRef( aggregateUseType, "u" );
 		else mangleRef( aggregateUseType, "u" );
 	}
 
-	void Mangler::visit( EnumInstType *aggregateUseType ) {
+	void Mangler::visit( EnumInstType * aggregateUseType ) {
 		mangleRef( aggregateUseType, "e" );
 	}
 
-	void Mangler::visit( TypeInstType *typeInst ) {
+	void Mangler::visit( TypeInstType * typeInst ) {
 		VarMapType::iterator varNum = varNums.find( typeInst->get_name() );
 		if ( varNum == varNums.end() ) {
@@ -233,27 +233,27 @@
 	}
 
-	void Mangler::visit( TupleType *tupleType ) {
+	void Mangler::visit( TupleType * tupleType ) {
 		printQualifiers( tupleType );
 		mangleName << "T";
-		acceptAll( tupleType->get_types(), *this );
+		acceptAll( tupleType->types, *this );
 		mangleName << "_";
 	}
 
-	void Mangler::visit( VarArgsType *varArgsType ) {
+	void Mangler::visit( VarArgsType * varArgsType ) {
 		printQualifiers( varArgsType );
 		mangleName << "VARGS";
 	}
 
-	void Mangler::visit( __attribute__((unused)) ZeroType *zeroType ) {
+	void Mangler::visit( ZeroType * ) {
 		mangleName << "Z";
 	}
 
-	void Mangler::visit( __attribute__((unused)) OneType *oneType ) {
+	void Mangler::visit( OneType * ) {
 		mangleName << "O";
 	}
 
-	void Mangler::visit( TypeDecl *decl ) {
+	void Mangler::visit( TypeDecl * decl ) {
 		static const char *typePrefix[] = { "BT", "BD", "BF" };
-		mangleName << typePrefix[ decl->get_kind() ] << ( decl->get_name().length() + 1 ) << decl->get_name();
+		mangleName << typePrefix[ decl->get_kind() ] << ( decl->name.length() + 1 ) << decl->name;
 	}
 
@@ -264,5 +264,5 @@
 	}
 
-	void Mangler::printQualifiers( Type *type ) {
+	void Mangler::printQualifiers( Type * type ) {
 		// skip if not including qualifiers
 		if ( typeMode ) return;
@@ -272,5 +272,5 @@
 			int tcount = 0, dcount = 0, fcount = 0, vcount = 0;
 			mangleName << "A";
-			for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
+			for ( Type::ForallList::iterator i = type->forall.begin(); i != type->forall.end(); ++i ) {
 				switch ( (*i)->get_kind() ) {
 				  case TypeDecl::Any:
@@ -289,6 +289,6 @@
 					assert( false );
 				} // switch
-				varNums[ (*i )->get_name() ] = std::pair< int, int >( nextVarNum++, (int )(*i )->get_kind() );
-				for ( std::list< DeclarationWithType* >::iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
+				varNums[ (*i)->name ] = std::pair< int, int >( nextVarNum++, (int)(*i)->get_kind() );
+				for ( std::list< DeclarationWithType* >::iterator assert = (*i)->assertions.begin(); assert != (*i)->assertions.end(); ++assert ) {
 					Mangler sub_mangler( mangleOverridable, typeMode );
 					sub_mangler.nextVarNum = nextVarNum;
@@ -309,4 +309,7 @@
 			mangleName << "V";
 		} // if
+		if ( type->get_mutex() ) {
+			mangleName << "M";
+		} // if
 		// Removed due to restrict not affecting function compatibility in GCC
 //		if ( type->get_isRestrict() ) {
@@ -314,6 +317,7 @@
 //		} // if
 		if ( type->get_lvalue() ) {
+			// mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues
 			mangleName << "L";
-		} // if
+		}
 		if ( type->get_atomic() ) {
 			mangleName << "A";
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision 201aeb9b7c42eb7c7aa8bc065247bffda4932b33)
+++ src/SymTab/Validate.cc	(revision 5dc26f53998df11e71288f9072c8d8f0ff8eafbf)
@@ -56,4 +56,5 @@
 #include "FixFunction.h"               // for FixFunction
 #include "Indexer.h"                   // for Indexer
+#include "InitTweak/GenInit.h"         // for fixReturnStatements
 #include "InitTweak/InitTweak.h"       // for isCtorDtorAssign
 #include "Parser/LinkageSpec.h"        // for C
@@ -150,6 +151,6 @@
 	/// Replaces array and function types in forall lists by appropriate pointer type and assigns each Object and Function declaration a unique ID.
 	struct ForallPointerDecay final {
-		void previsit( ObjectDecl *object );
-		void previsit( FunctionDecl *func );
+		void previsit( ObjectDecl * object );
+		void previsit( FunctionDecl * func );
 	};
 
@@ -579,6 +580,6 @@
 
 	/// Fix up assertions - flattens assertion lists, removing all trait instances
-	void forallFixer( Type * func ) {
-		for ( TypeDecl * type : func->get_forall() ) {
+	void forallFixer( std::list< TypeDecl * > & forall, BaseSyntaxNode * node ) {
+		for ( TypeDecl * type : forall ) {
 			std::list< DeclarationWithType * > asserts;
 			asserts.splice( asserts.end(), type->assertions );
@@ -599,5 +600,5 @@
 				assertion = assertion->acceptMutator( fixer );
 				if ( fixer.get_isVoid() ) {
-					throw SemanticError( "invalid type void in assertion of function ", func );
+					throw SemanticError( "invalid type void in assertion of function ", node );
 				} // if
 			} // for
@@ -607,7 +608,7 @@
 
 	void ForallPointerDecay::previsit( ObjectDecl *object ) {
-		forallFixer( object->get_type() );
-		if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
-			forallFixer( pointer->get_base() );
+		forallFixer( object->type->forall, object );
+		if ( PointerType *pointer = dynamic_cast< PointerType * >( object->type ) ) {
+			forallFixer( pointer->base->forall, object );
 		} // if
 		object->fixUniqueId();
@@ -615,5 +616,5 @@
 
 	void ForallPointerDecay::previsit( FunctionDecl *func ) {
-		forallFixer( func->get_type() );
+		forallFixer( func->type->forall, func );
 		func->fixUniqueId();
 	}
