Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision fea7ca72a864654b68ee68c30d09b8423c12bc64)
+++ src/InitTweak/FixInit.cc	(revision a1d6d80c1ef8e65ed06f390d2aed4fac6d418b6e)
@@ -10,5 +10,5 @@
 // Created On       : Wed Jan 13 16:29:30 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri Apr 29 12:25:40 2016
+// Last Modified On : Mon May 02 14:57:45 2016
 // Update Count     : 30
 //
@@ -61,4 +61,6 @@
 		/// true if type does not need to be copy constructed to ensure correctness
 		bool skipCopyConstruct( Type * );
+	private:
+		TypeSubstitution * env;
 	};
 
@@ -151,13 +153,14 @@
 		// wrap each function call so that it is easy to identify nodes that have to be copy constructed
 		ImplicitCopyCtorExpr * expr = new ImplicitCopyCtorExpr( appExpr );
-		// save a copy of the type substitution onto the new node so that it is easy to find.
+		// save the type substitution onto the new node so that it is easy to find.
+		// Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion.
 		// The substitution is needed to obtain the type of temporary variables so that copy constructor
 		// calls can be resolved. Normally this is what PolyMutator is for, but the pass that resolves
 		// copy constructor calls must be an Indexer. We could alternatively make a PolyIndexer which
-		// saves the environment, or compute the types of temporaries here, but it's more simpler to
+		// saves the environment, or compute the types of temporaries here, but it's much simpler to
 		// save the environment here, and more cohesive to compute temporary variables and resolve copy
 		// constructor calls together.
 		assert( env );
-		expr->set_env( env->clone() );
+		expr->set_env( env );
 		return expr;
 	}
@@ -178,4 +181,7 @@
 		PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
 		ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
+		if ( resolved->get_env() ) {
+			env->add( *resolved->get_env() );
+		}
 
 		assert( resolved );
@@ -190,4 +196,5 @@
 		PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
 		Visitor::visit( impCpCtorExpr );
+		env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer...
 
 		ApplicationExpr * appExpr = impCpCtorExpr->get_callExpr();
@@ -246,5 +253,4 @@
 		PRINT( std::cerr << "FixCopyCtors: " << impCpCtorExpr << std::endl; )
 
-		// assert( impCpCtorExpr->get_callExpr()->get_env() );
 		impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( Mutator::mutate( impCpCtorExpr ) );
 		assert( impCpCtorExpr );
@@ -278,4 +284,5 @@
 		returnDecls.clear();
 		impCpCtorExpr->set_callExpr( NULL );
+		impCpCtorExpr->set_env( NULL );
 		delete impCpCtorExpr;
 
@@ -311,4 +318,6 @@
 				retExpr = deref;
 			}
+			// xxx - might need to set env on retExpr...
+			// retExpr->set_env( env->clone() );
 			return retExpr;
 		} else {
