Index: src/SynTree/Mutator.cc
===================================================================
--- src/SynTree/Mutator.cc	(revision 8bf784a480c5767f00136e0ea0f9174c442f327f)
+++ src/SynTree/Mutator.cc	(revision e33f3213eb817855f65c2c1a3a7e12bdcc2831e5)
@@ -23,4 +23,5 @@
 #include "Constant.h"
 #include "Common/utility.h"
+#include "TypeSubstitution.h"
 
 Mutator::Mutator() {}
@@ -178,4 +179,5 @@
 
 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
+	applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
 	applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
 	applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
@@ -185,4 +187,5 @@
 
 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
+	untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
 	untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
 	mutateAll( untypedExpr->get_args(), *this );
@@ -191,4 +194,5 @@
 
 Expression *Mutator::mutate( NameExpr *nameExpr ) {
+	nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
 	nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
 	return nameExpr;
@@ -196,4 +200,5 @@
 
 Expression *Mutator::mutate( AddressExpr *addressExpr ) {
+	addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
 	addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
 	addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
@@ -202,4 +207,5 @@
 
 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
+	labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
 	labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
 	labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
@@ -208,4 +214,5 @@
 
 Expression *Mutator::mutate( CastExpr *castExpr ) {
+	castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
 	castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
 	castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
@@ -214,4 +221,5 @@
 
 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
+	memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
 	memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
 	memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
@@ -221,4 +229,5 @@
 
 Expression *Mutator::mutate( MemberExpr *memberExpr ) {
+	memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
 	memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
 	memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
@@ -227,4 +236,5 @@
 
 Expression *Mutator::mutate( VariableExpr *variableExpr ) {
+	variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
 	variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
 	return variableExpr;
@@ -232,4 +242,5 @@
 
 Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
+	constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
 	constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
 //  maybeMutate( constantExpr->get_constant(), *this )
@@ -238,4 +249,5 @@
 
 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
+	sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
 	sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
 	if ( sizeofExpr->get_isType() ) {
@@ -248,4 +260,5 @@
 
 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
+	alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
 	alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
 	if ( alignofExpr->get_isType() ) {
@@ -258,4 +271,5 @@
 
 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
+	offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
 	offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
 	offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
@@ -264,4 +278,5 @@
 
 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
+	offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
 	offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
 	offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
@@ -271,4 +286,5 @@
 
 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
+	offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
 	offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
 	offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
@@ -277,4 +293,5 @@
 
 Expression *Mutator::mutate( AttrExpr *attrExpr ) {
+	attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
 	attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
 	if ( attrExpr->get_isType() ) {
@@ -287,4 +304,5 @@
 
 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
+	logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
 	logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
 	logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
@@ -294,4 +312,5 @@
 
 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
+	conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
 	conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
 	conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
@@ -302,4 +321,5 @@
 
 Expression *Mutator::mutate( CommaExpr *commaExpr ) {
+	commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
 	commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
 	commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
@@ -309,4 +329,5 @@
 
 Expression *Mutator::mutate( TypeExpr *typeExpr ) {
+	typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
 	typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
 	typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
@@ -315,4 +336,5 @@
 
 Expression *Mutator::mutate( AsmExpr *asmExpr ) {
+	asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
 	asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
 	asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
@@ -322,4 +344,5 @@
 
 Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
+	impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
 	impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
 	mutateAll( impCpCtorExpr->get_tempDecls(), *this );
@@ -330,4 +353,5 @@
 
 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
+	ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
 	ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
 	ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
@@ -336,4 +360,5 @@
 
 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
+	compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
 	compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
 	compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
@@ -343,4 +368,5 @@
 
 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
+	valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
 	valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
 	return valofExpr;
@@ -348,4 +374,5 @@
 
 Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
+	rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
 	rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
 	rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
@@ -354,4 +381,5 @@
 
 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
+	tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 	tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 	mutateAll( tupleExpr->get_exprs(), *this );
@@ -360,4 +388,5 @@
 
 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
+	tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 	tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 	tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
@@ -366,4 +395,5 @@
 
 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
+	tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 	tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 	tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
@@ -373,4 +403,5 @@
 
 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
+	assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
 	assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
 	assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
@@ -379,4 +410,5 @@
 
 Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
+	stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
 	stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
 	stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
@@ -387,4 +419,5 @@
 
 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
+	uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
 	uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
 	uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
Index: src/SynTree/TypeSubstitution.cc
===================================================================
--- src/SynTree/TypeSubstitution.cc	(revision 8bf784a480c5767f00136e0ea0f9174c442f327f)
+++ src/SynTree/TypeSubstitution.cc	(revision e33f3213eb817855f65c2c1a3a7e12bdcc2831e5)
@@ -231,4 +231,14 @@
 }
 
+TypeSubstitution * TypeSubstitution::acceptMutator( Mutator & mutator ) {
+	for ( auto & p : typeEnv ) {
+		p.second = maybeMutate( p.second, mutator );
+	}
+	for ( auto & p : varEnv ) {
+		p.second = maybeMutate( p.second, mutator );
+	}
+	return this;
+}
+
 void TypeSubstitution::print( std::ostream &os, int indent ) const {
 	os << std::string( indent, ' ' ) << "Types:" << std::endl;
Index: src/SynTree/TypeSubstitution.h
===================================================================
--- src/SynTree/TypeSubstitution.h	(revision 8bf784a480c5767f00136e0ea0f9174c442f327f)
+++ src/SynTree/TypeSubstitution.h	(revision e33f3213eb817855f65c2c1a3a7e12bdcc2831e5)
@@ -53,4 +53,6 @@
 
 	void normalize();
+
+	TypeSubstitution * acceptMutator( Mutator & mutator );
 
 	void print( std::ostream &os, int indent = 0 ) const;
