Index: src/ControlStruct/ExceptTranslate.cc
===================================================================
--- src/ControlStruct/ExceptTranslate.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/ControlStruct/ExceptTranslate.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -315,11 +315,11 @@
 			{
 				VarExprReplacer::DeclMap mapping;
-				mapping[ handler_decl ] = local_except;
+				mapping[ handler_decl ] = new VariableExpr( local_except );
 				VarExprReplacer mapper( mapping );
-				handler->get_body()->accept( mapper );
+				handler->body->acceptMutator( mapper );
 			}
 
-			block->push_back( handler->get_body() );
-			handler->set_body( nullptr );
+			block->push_back( handler->body );
+			handler->body = nullptr;
 
 			std::list<Statement *> caseBody
Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/InitTweak/FixInit.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -54,4 +54,5 @@
 #include "SynTree/Type.h"              // for Type, Type::StorageClasses
 #include "SynTree/TypeSubstitution.h"  // for TypeSubstitution, operator<<
+#include "SynTree/VarExprReplacer.h"   // for VarExprReplacer
 #include "SynTree/Visitor.h"           // for acceptAll, maybeAccept
 
@@ -158,10 +159,6 @@
 			using Parent::previsit;
 
-			void previsit( ObjectDecl * objDecl );
 			void previsit( FunctionDecl * funcDecl );
 
-			void previsit( CompoundStmt * compoundStmt );
-			void postvisit( CompoundStmt * compoundStmt );
-			void previsit( ReturnStmt * returnStmt );
 			void previsit( BranchStmt * stmt );
 		private:
@@ -203,4 +200,6 @@
 			static void generate( std::list< Declaration * > & translationUnit );
 
+			void previsit( StructDecl * structDecl );
+
 			void previsit( FunctionDecl * funcDecl );
 			void postvisit( FunctionDecl * funcDecl );
@@ -220,4 +219,8 @@
 			bool isCtor = false; // true if current function is a constructor
 			StructDecl * structDecl = nullptr;
+
+			// special built-in functions necessary for this to work
+			StructDecl * dtorStruct = nullptr;
+			FunctionDecl * dtorStructDestroy = nullptr;
 		};
 
@@ -644,4 +647,55 @@
 		}
 
+		DeclarationWithType * getDtorFunc( ObjectDecl * objDecl, Statement * input, std::list< Statement * > & stmtsToAdd ) {
+			// unwrap implicit statement wrapper
+			Statement * dtor = input;
+			if ( ImplicitCtorDtorStmt * implicit = dynamic_cast< ImplicitCtorDtorStmt * >( input ) ) {
+				// dtor = implicit->callStmt;
+				// implicit->callStmt = nullptr;
+			}
+			assert( dtor );
+			std::list< Expression * > matches;
+			collectCtorDtorCalls( dtor, matches );
+
+			if ( dynamic_cast< ExprStmt * >( dtor ) ) {
+				// only one destructor call in the expression
+				if ( matches.size() == 1 ) {
+					DeclarationWithType * func = getFunction( matches.front() );
+					assertf( func, "getFunction failed to find function in %s", toString( matches.front() ).c_str() );
+
+					// cleanup argument must be a function, not an object (including function pointer)
+					if ( FunctionDecl * dtorFunc = dynamic_cast< FunctionDecl * > ( func ) ) {
+						if ( dtorFunc->type->forall.empty() ) {
+							// simple case where the destructor is a monomorphic function call - can simply
+							// use that function as the cleanup function.
+							delete dtor;
+							return func;
+						}
+					}
+				}
+			}
+
+			// otherwise the cleanup is more complicated - need to build a single argument cleanup function that
+			// wraps the more complicated code.
+			static UniqueName dtorNamer( "__cleanup_dtor" );
+			FunctionDecl * dtorFunc = FunctionDecl::newFunction( dtorNamer.newName(), SymTab::genDefaultType( objDecl->type->stripReferences(), false ), new CompoundStmt( noLabels ) );
+			stmtsToAdd.push_back( new DeclStmt( noLabels, dtorFunc ) );
+
+			// the original code contains uses of objDecl - replace them with the newly generated 'this' parameter.
+			ObjectDecl * thisParam = getParamThis( dtorFunc->type );
+			Expression * replacement = new VariableExpr( thisParam );
+
+			Type * base = replacement->result->stripReferences();
+			if ( dynamic_cast< ArrayType * >( base ) || dynamic_cast< TupleType * > ( base ) ) {
+				// need to cast away reference for array types, since the destructor is generated without the reference type,
+				// and for tuple types since tuple indexing does not work directly on a reference
+				replacement = new CastExpr( replacement, base->clone() );
+			}
+			VarExprReplacer::replace( dtor, { std::make_pair( objDecl, replacement ) } );
+			dtorFunc->statements->push_back( dtor );
+
+			return dtorFunc;
+		}
+
 		DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) {
 			// since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
@@ -756,4 +810,19 @@
 							ctorInit->ctor = nullptr;
 						}
+
+						Statement * dtor = ctorInit->dtor;
+						if ( dtor ) {
+							ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * >( dtor );
+							Statement * dtorStmt = implicit->callStmt;
+
+							// don't need to call intrinsic dtor, because it does nothing, but
+							// non-intrinsic dtors must be called
+							if ( ! isIntrinsicSingleArgCallStmt( dtorStmt ) ) {
+								// set dtor location to the object's location for error messages
+								DeclarationWithType * dtorFunc = getDtorFunc( objDecl, dtorStmt, stmtsToAddBefore );
+								objDecl->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( dtorFunc ) } ) );
+								ctorInit->dtor = nullptr;
+							} // if
+						}
 					} // if
 				} else if ( Initializer * init = ctorInit->init ) {
@@ -798,36 +867,4 @@
 
 
-		template<typename Iterator, typename OutputIterator>
-		void insertDtors( Iterator begin, Iterator end, OutputIterator out ) {
-			for ( Iterator it = begin ; it != end ; ++it ) {
-				// extract destructor statement from the object decl and insert it into the output. Note that this is
-				// only called on lists of non-static objects with implicit non-intrinsic dtors, so if the user manually
-				// calls an intrinsic dtor then the call must (and will) still be generated since the argument may
-				// contain side effects.
-				ObjectDecl * objDecl = *it;
-				ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() );
-				assert( ctorInit && ctorInit->get_dtor() );
-				*out++ = ctorInit->get_dtor()->clone();
-			} // for
-		}
-
-		void InsertDtors::previsit( ObjectDecl * objDecl ) {
-			// remember non-static destructed objects so that their destructors can be inserted later
-			if ( ! objDecl->get_storageClasses().is_static ) {
-				if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
-					// a decision should have been made by the resolver, so ctor and init are not both non-NULL
-					assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
-					Statement * dtor = ctorInit->get_dtor();
-					// don't need to call intrinsic dtor, because it does nothing, but
-					// non-intrinsic dtors must be called
-					if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) {
-						// set dtor location to the object's location for error messages
-						ctorInit->dtor->location = objDecl->location;
-						reverseDeclOrder.front().push_front( objDecl );
-					} // if
-				} // if
-			} // if
-		}
-
 		void InsertDtors::previsit( FunctionDecl * funcDecl ) {
 			// each function needs to have its own set of labels
@@ -842,29 +879,4 @@
 		}
 
-		void InsertDtors::previsit( CompoundStmt * compoundStmt ) {
-			// visit statements - this will also populate reverseDeclOrder list.  don't want to dump all destructors
-			// when block is left, just the destructors associated with variables defined in this block, so push a new
-			// list to the top of the stack so that we can differentiate scopes
-			reverseDeclOrder.push_front( OrderedDecls() );
-			Parent::previsit( compoundStmt );
-		}
-
-		void InsertDtors::postvisit( CompoundStmt * compoundStmt ) {
-			// add destructors for the current scope that we're exiting, unless the last statement is a return, which
-			// causes unreachable code warnings
-			std::list< Statement * > & statements = compoundStmt->get_kids();
-			if ( ! statements.empty() && ! dynamic_cast< ReturnStmt * >( statements.back() ) ) {
-				insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( statements ) );
-			}
-			reverseDeclOrder.pop_front();
-		}
-
-		void InsertDtors::previsit( ReturnStmt * ) {
-			// return exits all scopes, so dump destructors for all scopes
-			for ( OrderedDecls & od : reverseDeclOrder ) {
-				insertDtors( od.begin(), od.end(), back_inserter( stmtsToAddBefore ) );
-			} // for
-		}
-
 		// Handle break/continue/goto in the same manner as C++.  Basic idea: any objects that are in scope at the
 		// BranchStmt but not at the labelled (target) statement must be destructed.  If there are any objects in scope
@@ -894,22 +906,4 @@
 			if ( ! diff.empty() ) {
 				throw SemanticError( std::string("jump to label '") + stmt->get_target().get_name() + "' crosses initialization of " + (*diff.begin())->get_name() + " ", stmt );
-			} // if
-			// S_G-S_L results in set of objects that must be destructed
-			diff.clear();
-			std::set_difference( curVars.begin(), curVars.end(), lvars.begin(), lvars.end(), std::inserter( diff, diff.end() ) );
-			DTOR_PRINT(
-				std::cerr << "S_G-S_L = " << printSet( diff ) << std::endl;
-			)
-			if ( ! diff.empty() ) {
-				// create an auxilliary set for fast lookup -- can't make diff a set, because diff ordering should be consistent for error messages.
-				std::unordered_set<ObjectDecl *> needsDestructor( diff.begin(), diff.end() );
-
-				// go through decl ordered list of objectdecl. for each element that occurs in diff, output destructor
-				OrderedDecls ordered;
-				for ( OrderedDecls & rdo : reverseDeclOrder ) {
-					// add elements from reverseDeclOrder into ordered if they occur in diff - it is key that this happens in reverse declaration order.
-					copy_if( rdo.begin(), rdo.end(), back_inserter( ordered ), [&]( ObjectDecl * objDecl ) { return needsDestructor.count( objDecl ); } );
-				} // for
-				insertDtors( ordered.begin(), ordered.end(), back_inserter( stmtsToAddBefore ) );
 			} // if
 		}
@@ -937,4 +931,10 @@
 		}
 
+		void GenStructMemberCalls::previsit( StructDecl * structDecl ) {
+			if ( ! dtorStruct && structDecl->name == "__Destructor" ) {
+				dtorStruct = structDecl;
+			}
+		}
+
 		void GenStructMemberCalls::previsit( FunctionDecl * funcDecl ) {
 			GuardValue( function );
@@ -949,4 +949,9 @@
 			unhandled.clear();
 			usedUninit.clear();
+
+			if ( ! dtorStructDestroy && funcDecl->name == "__destroy_Destructor" ) {
+				dtorStructDestroy = funcDecl;
+				return;
+			}
 
 			function = funcDecl;
@@ -960,4 +965,5 @@
 				if ( structType ) {
 					structDecl = structType->get_baseStruct();
+					if ( structDecl == dtorStruct ) return;
 					for ( Declaration * member : structDecl->get_members() ) {
 						if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
@@ -1029,8 +1035,29 @@
 							callStmt->acceptMutator( resolver );
 							if ( isCtor ) {
-								function->get_statements()->push_front( callStmt );
+								function->statements->push_front( callStmt );
 							} else {
 								// destructor statements should be added at the end
-								function->get_statements()->push_back( callStmt );
+								// function->get_statements()->push_back( callStmt );
+
+								// Destructor _dtor0 = { &b.a1, (void (*)(void *)_destroy_A };
+								std::list< Statement * > stmtsToAdd;
+
+								static UniqueName memberDtorNamer = { "__memberDtor" };
+								assertf( dtorStruct, "builtin __Destructor not found." );
+								assertf( dtorStructDestroy, "builtin __destroy_Destructor not found." );
+
+								Expression * thisExpr = new AddressExpr( new VariableExpr( thisParam ) );
+								Expression * dtorExpr = new VariableExpr( getDtorFunc( thisParam, callStmt, stmtsToAdd ) );
+
+								// cast destructor pointer to void (*)(void *), to silence GCC incompatible pointer warnings
+								FunctionType * dtorFtype = new FunctionType( Type::Qualifiers(), false );
+								dtorFtype->parameters.push_back( ObjectDecl::newObject( "", new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), nullptr ) );
+								Type * dtorType = new PointerType( Type::Qualifiers(), dtorFtype );
+
+								ObjectDecl * destructor = ObjectDecl::newObject( memberDtorNamer.newName(), new StructInstType( Type::Qualifiers(), dtorStruct ), new ListInit( { new SingleInit( thisExpr ), new SingleInit( new CastExpr( dtorExpr, dtorType ) ) } ) );
+								function->statements->push_front( new DeclStmt( noLabels, destructor ) );
+								destructor->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( dtorStructDestroy ) } ) );
+
+								function->statements->kids.splice( function->statements->kids.begin(), stmtsToAdd );
 							}
 						} catch ( SemanticError & error ) {
Index: src/InitTweak/InitTweak.cc
===================================================================
--- src/InitTweak/InitTweak.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/InitTweak/InitTweak.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -345,5 +345,5 @@
 		std::list< Expression * > matches;
 		collectCtorDtorCalls( stmt, matches );
-		assert( matches.size() <= 1 );
+		assertf( matches.size() <= 1, "%zd constructor/destructors found in %s", matches.size(), toString( stmt ).c_str() );
 		return matches.size() == 1 ? matches.front() : nullptr;
 	}
Index: src/SymTab/Autogen.cc
===================================================================
--- src/SymTab/Autogen.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SymTab/Autogen.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -46,5 +46,5 @@
 	/// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
 	struct FuncData {
-		typedef FunctionType * (*TypeGen)( Type * );
+		typedef FunctionType * (*TypeGen)( Type *, bool );
 		FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {}
 		std::string fname;
@@ -232,8 +232,11 @@
 
 	/// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
-	FunctionType * genDefaultType( Type * paramType ) {
-		const auto & typeParams = getGenericParams( paramType );
+	FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
 		FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
-		cloneAll( typeParams, ftype->forall );
+		if ( maybePolymorphic ) {
+			// only copy in
+			const auto & typeParams = getGenericParams( paramType );
+			cloneAll( typeParams, ftype->forall );
+		}
 		ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
 		ftype->parameters.push_back( dstParam );
@@ -242,6 +245,6 @@
 
 	/// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
-	FunctionType * genCopyType( Type * paramType ) {
-		FunctionType *ftype = genDefaultType( paramType );
+	FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
+		FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
 		ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
 		ftype->parameters.push_back( srcParam );
@@ -250,6 +253,6 @@
 
 	/// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
-	FunctionType * genAssignType( Type * paramType ) {
-		FunctionType *ftype = genCopyType( paramType );
+	FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
+		FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
 		ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
 		ftype->returnVals.push_back( returnVal );
@@ -309,5 +312,5 @@
 		for ( const FuncData & d : data ) {
 			// generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
-			FunctionType * ftype = d.genType( type );
+			FunctionType * ftype = d.genType( type, true );
 
 			// destructor for concurrent type must be mutex
Index: src/SymTab/Autogen.h
===================================================================
--- src/SymTab/Autogen.h	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SymTab/Autogen.h	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -45,12 +45,15 @@
 	extern FunctionDecl * dereferenceOperator;
 
-	// generate the type of an assignment function for paramType
-	FunctionType * genAssignType( Type * paramType );
-
-	// generate the type of a default constructor or destructor for paramType
-	FunctionType * genDefaultType( Type * paramType );
-
-	// generate the type of a copy constructor for paramType
-	FunctionType * genCopyType( Type * paramType );
+	/// generate the type of an assignment function for paramType.
+	/// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
+	FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true );
+
+	/// generate the type of a default constructor or destructor for paramType.
+	/// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
+	FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true );
+
+	/// generate the type of a copy constructor for paramType.
+	/// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
+	FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true );
 
 	/// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
Index: src/SynTree/CompoundStmt.cc
===================================================================
--- src/SynTree/CompoundStmt.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SynTree/CompoundStmt.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -59,5 +59,5 @@
 				DeclarationWithType * origdwt = strict_dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
 				assert( dwt->get_name() == origdwt->get_name() );
-				declMap[ origdwt ] = dwt;
+				declMap[ origdwt ] = new VariableExpr( dwt );
 			} else assert( ! dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ) );
 		} else assert( ! dynamic_cast< DeclStmt * > ( s ) );
@@ -65,5 +65,5 @@
 	if ( ! declMap.empty() ) {
 		VarExprReplacer replacer( declMap );
-		accept( replacer );
+		acceptMutator( replacer );
 	}
 }
Index: src/SynTree/FunctionDecl.cc
===================================================================
--- src/SynTree/FunctionDecl.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SynTree/FunctionDecl.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -43,12 +43,12 @@
 	VarExprReplacer::DeclMap declMap;
 	for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
-		declMap[ std::get<0>(p) ] = std::get<1>(p);
+		declMap[ std::get<0>(p) ] = new VariableExpr( std::get<1>(p) );
 	}
 	for ( auto p : group_iterate( other.type->returnVals, type->returnVals ) ) {
-		declMap[ std::get<0>(p) ] = std::get<1>(p);
+		declMap[ std::get<0>(p) ] = new VariableExpr( std::get<1>(p) );
 	}
 	if ( ! declMap.empty() ) {
 		VarExprReplacer replacer( declMap );
-		accept( replacer );
+		acceptMutator( replacer );
 	}
 }
Index: src/SynTree/Mutator.h
===================================================================
--- src/SynTree/Mutator.h	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SynTree/Mutator.h	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -119,4 +119,5 @@
 
 	virtual TypeSubstitution * mutate( TypeSubstitution * sub );
+
   private:
 	virtual Declaration * handleAggregateDecl(AggregateDecl * aggregateDecl );
Index: src/SynTree/VarExprReplacer.cc
===================================================================
--- src/SynTree/VarExprReplacer.cc	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SynTree/VarExprReplacer.cc	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -22,12 +22,21 @@
 VarExprReplacer::VarExprReplacer( const DeclMap & declMap, bool debug ) : declMap( declMap ), debug( debug ) {}
 
-// replace variable with new node from decl map
-void VarExprReplacer::visit( VariableExpr * varExpr ) {
-	// xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
-	if ( declMap.count( varExpr->get_var() ) ) {
-		if ( debug ) {
-			std::cerr << "replacing variable reference: " << (void*)varExpr->get_var() << " " << varExpr->get_var() << " with " << (void*)declMap.at( varExpr->get_var() ) << " " << declMap.at( varExpr->get_var() ) << std::endl;
-		}
-		varExpr->set_var( declMap.at( varExpr->get_var() ) );
+VarExprReplacer::~VarExprReplacer() {
+	for ( auto p : declMap ) {
+		delete p.second;
 	}
 }
+
+// replace variable with new node from decl map
+Expression * VarExprReplacer::mutate( VariableExpr * varExpr ) {
+	// xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
+	if ( declMap.count( varExpr->var ) ) {
+		Expression * expr = declMap.at( varExpr->var );
+		if ( debug ) {
+			std::cerr << "replacing variable reference: " << (void*)varExpr->var << " " << varExpr->var << " with " << (void*)expr << " " << expr << std::endl;
+		}
+		delete varExpr;
+		return expr->clone();
+	}
+	return varExpr;
+}
Index: src/SynTree/VarExprReplacer.h
===================================================================
--- src/SynTree/VarExprReplacer.h	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/SynTree/VarExprReplacer.h	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -24,7 +24,7 @@
 
 /// Visitor that replaces the declarations that VariableExprs refer to, according to the supplied mapping
-class VarExprReplacer : public Visitor {
+class VarExprReplacer : public Mutator {
 public:
-	typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
+	typedef std::map< DeclarationWithType *, Expression * > DeclMap;
 private:
 	const DeclMap & declMap;
@@ -32,11 +32,13 @@
 public:
 	VarExprReplacer( const DeclMap & declMap, bool debug = false );
+	~VarExprReplacer();
 
 	// replace variable with new node from decl map
-	virtual void visit( VariableExpr * varExpr );
+	virtual Expression * mutate( VariableExpr * varExpr );
 
-	static void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false ) {
+	template<typename Node>
+	static void replace( Node *& node, const DeclMap & declMap, bool debug = false ) {
 		VarExprReplacer replacer( declMap, debug );
-		maybeAccept( node, replacer );
+		node = maybeMutate( node, replacer );
 	}
 };
Index: src/prelude/builtins.c
===================================================================
--- src/prelude/builtins.c	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/prelude/builtins.c	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -96,4 +96,25 @@
 static inline unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; }
 
+// type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
+forall(dtype T)
+struct __Destructor {
+  T * object;
+  void (*dtor)(T *);
+};
+
+// defined destructor in the case that non-generated code wants to use __Destructor
+forall(dtype T)
+static inline void ^?{}(__Destructor(T) & x) {
+  x.dtor(x.object);
+}
+
+// easy interface into __Destructor's destructor for easy codegen purposes
+extern "C" {
+  forall(dtype T)
+  static inline void __destroy_Destructor(__Destructor(T) * dtor) {
+    ^(*dtor){};
+  }
+}
+
 // Local Variables: //
 // mode: c //
Index: src/tests/.expect/memberCtors-ERR1.txt
===================================================================
--- src/tests/.expect/memberCtors-ERR1.txt	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/tests/.expect/memberCtors-ERR1.txt	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -1,1 +1,1 @@
-memberCtors.c:71:1 error: in void ?{}(B &b), field a2 used before being constructed
+memberCtors.c:78:1 error: in void ?{}(B &b), field a2 used before being constructed
Index: src/tests/.expect/memberCtors.txt
===================================================================
--- src/tests/.expect/memberCtors.txt	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/tests/.expect/memberCtors.txt	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -98,4 +98,5 @@
 end copy construct A
 End of main
+begin destruct B
 constructing int
 constructing int
@@ -146,13 +147,15 @@
 destructing int: 0
 destructing int: 1000
-destructing int: 0
-destructing int: 0
-destructing int: 999
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 999
+end destruct B
+destructing int: 0
+destructing int: 0
+destructing int: 999
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 999
+begin destruct B
 constructing int
 constructing int
@@ -203,11 +206,12 @@
 destructing int: 0
 destructing int: 1000
-destructing int: 0
-destructing int: 0
-destructing int: 999
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 0
-destructing int: 999
+end destruct B
+destructing int: 0
+destructing int: 0
+destructing int: 999
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 0
+destructing int: 999
Index: src/tests/memberCtors.c
===================================================================
--- src/tests/memberCtors.c	(revision 389528b064cb7e3dd189f2b539211687b2f09352)
+++ src/tests/memberCtors.c	(revision 9c3543102dd7ddc536fce11908c849a078505fc7)
@@ -22,8 +22,15 @@
 }
 
-void ?=?(WrappedInt & this, int x) {
+/* WrappedInt */ void ?=?(WrappedInt & this, int x) {
   printf("assigning int: %d %d\n", this.x, x);
   this.x = x;
+  // return this;
 }
+
+// WrappedInt ?=?(WrappedInt & this, WrappedInt other) {
+//   printf("assigning int: %d %d\n", this.x, other.x);
+//   this.x = other.x;
+//   return this;
+// }
 
 struct A {
@@ -79,11 +86,13 @@
 
 void ^?{}(B & b) {
+  printf("begin destruct B\n");
   b.a2 = (A) { 0 };
   ^(b.a1){};
+  printf("end destruct B\n");
 } // a2, a3 never destructed - will be automatically destructed
 
 int main() {
   printf("Before declaration of b1\n");
-  B b1;
+  B b1;  // b1 = { { 1000, 0, 0 }, { 1001, 0, 0 }, { 0, 0, 0 } }
   printf("Before declaration of b2\n");
   B b2 = b1;
