Index: src/SynTree/Mutator.cc
===================================================================
--- src/SynTree/Mutator.cc	(revision 6137fbb8754ddae70e06461364ee568113aaa3e3)
+++ src/SynTree/Mutator.cc	(revision 6fc5c14c6f831f36aaf4f6736da31f67985da917)
@@ -626,4 +626,14 @@
 }
 
+TypeSubstitution * Mutator::mutate( TypeSubstitution * sub ) {
+	for ( auto & p : sub->typeEnv ) {
+		p.second = maybeMutate( p.second, *this );
+	}
+	for ( auto & p : sub->varEnv ) {
+		p.second = maybeMutate( p.second, *this );
+	}
+	return sub;
+}
+
 // Local Variables: //
 // tab-width: 4 //
Index: src/SynTree/Mutator.h
===================================================================
--- src/SynTree/Mutator.h	(revision 6137fbb8754ddae70e06461364ee568113aaa3e3)
+++ src/SynTree/Mutator.h	(revision 6fc5c14c6f831f36aaf4f6736da31f67985da917)
@@ -117,4 +117,6 @@
 
 	virtual Attribute * mutate( Attribute * attribute );
+
+	virtual TypeSubstitution * mutate( TypeSubstitution * sub );
   private:
 	virtual Declaration * handleAggregateDecl(AggregateDecl * aggregateDecl );
Index: src/SynTree/TypeSubstitution.cc
===================================================================
--- src/SynTree/TypeSubstitution.cc	(revision 6137fbb8754ddae70e06461364ee568113aaa3e3)
+++ src/SynTree/TypeSubstitution.cc	(revision 6fc5c14c6f831f36aaf4f6736da31f67985da917)
@@ -148,5 +148,5 @@
 template< typename TypeClass >
 Type *TypeSubstitution::handleType( TypeClass *type ) {
-	BoundVarsType oldBoundVars( boundVars );
+	ValueGuard<BoundVarsType> oldBoundVars( boundVars );
 	// bind type variables from forall-qualifiers
 	if ( freeOnly ) {
@@ -156,5 +156,4 @@
 	} // if
 	Type *ret = Mutator::mutate( type );
-	boundVars = oldBoundVars;
 	return ret;
 }
@@ -162,5 +161,5 @@
 template< typename TypeClass >
 Type *TypeSubstitution::handleAggregateType( TypeClass *type ) {
-	BoundVarsType oldBoundVars( boundVars );
+	ValueGuard<BoundVarsType> oldBoundVars( boundVars );
 	// bind type variables from forall-qualifiers
 	if ( freeOnly ) {
@@ -177,5 +176,4 @@
 	} // if
 	Type *ret = Mutator::mutate( type );
-	boundVars = oldBoundVars;
 	return ret;
 }
@@ -231,14 +229,4 @@
 Type * TypeSubstitution::mutate( OneType *oneType ) {
 	return handleType( oneType );
-}
-
-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;
 }
 
Index: src/SynTree/TypeSubstitution.h
===================================================================
--- src/SynTree/TypeSubstitution.h	(revision 6137fbb8754ddae70e06461364ee568113aaa3e3)
+++ src/SynTree/TypeSubstitution.h	(revision 6fc5c14c6f831f36aaf4f6736da31f67985da917)
@@ -59,5 +59,5 @@
 	void normalize();
 
-	TypeSubstitution * acceptMutator( Mutator & mutator );
+	TypeSubstitution * acceptMutator( Mutator & m ) { return m.mutate( this ); }
 
 	void print( std::ostream &os, Indenter indent = {} ) const;
@@ -89,4 +89,9 @@
 
 	void initialize( const TypeSubstitution &src, TypeSubstitution &dest );
+
+	friend class Mutator;
+
+	template<typename pass_type>
+	friend class PassVisitor;
 
 	typedef std::map< std::string, Type* > TypeEnvType;
