Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision bfae637fd56b22bbc3c95a309296411f8ab7d9ed)
+++ src/GenPoly/Box.cc	(revision 6f49cdf3c1329b4fdca21be3f751faf62a3ee0b2)
@@ -664,5 +664,5 @@
 			if ( functionDecl->get_statements() ) {		// empty routine body ?
 				doBeginScope();
-				TyVarMap oldtyVars = scopeTyVars;
+				scopeTyVars.beginScope();;
 				assignOps.beginScope();
 				DeclarationWithType *oldRetval = retval;
@@ -706,5 +706,5 @@
 				functionDecl->set_statements( functionDecl->get_statements()->acceptMutator( *this ) );
 
-				scopeTyVars = oldtyVars;
+				scopeTyVars.endScope();
 				assignOps.endScope();
 				retval = oldRetval;
@@ -1456,20 +1456,20 @@
 
 		Type * Pass1::mutate( PointerType *pointerType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( pointerType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( pointerType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
 
 		Type * Pass1::mutate( FunctionType *functionType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( functionType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( functionType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
@@ -1536,15 +1536,15 @@
 
 		Type * Pass2::mutate( PointerType *pointerType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( pointerType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( pointerType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
 
 		Type *Pass2::mutate( FunctionType *funcType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( funcType, scopeTyVars );
 
@@ -1627,5 +1627,5 @@
 			mutateAll( funcType->get_parameters(), *this );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return funcType;
 		}
@@ -1824,10 +1824,10 @@
 		template< typename DeclClass >
 		DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( type, scopeTyVars );
 
 			DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
@@ -1851,15 +1851,15 @@
 
 		Type * PolyGenericCalculator::mutate( PointerType *pointerType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( pointerType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( pointerType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
 
 		Type * PolyGenericCalculator::mutate( FunctionType *funcType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( funcType, scopeTyVars );
 
@@ -1875,5 +1875,5 @@
 			Type *ret = Mutator::mutate( funcType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
@@ -2201,5 +2201,5 @@
 		template< typename DeclClass >
 		DeclClass * Pass3::handleDecl( DeclClass *decl, Type *type ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( type, scopeTyVars );
 
@@ -2207,5 +2207,5 @@
 			ScrubTyVars::scrub( decl, scopeTyVars );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
@@ -2237,20 +2237,20 @@
 
 		Type * Pass3::mutate( PointerType *pointerType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( pointerType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( pointerType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
 
 		Type * Pass3::mutate( FunctionType *functionType ) {
-			TyVarMap oldtyVars = scopeTyVars;
+			scopeTyVars.beginScope();
 			makeTyVarMap( functionType, scopeTyVars );
 
 			Type *ret = Mutator::mutate( functionType );
 
-			scopeTyVars = oldtyVars;
+			scopeTyVars.endScope();
 			return ret;
 		}
Index: src/GenPoly/FindFunction.cc
===================================================================
--- src/GenPoly/FindFunction.cc	(revision bfae637fd56b22bbc3c95a309296411f8ab7d9ed)
+++ src/GenPoly/FindFunction.cc	(revision 6f49cdf3c1329b4fdca21be3f751faf62a3ee0b2)
@@ -61,5 +61,5 @@
 
 	Type * FindFunction::mutate( FunctionType *functionType ) {
-		TyVarMap oldTyVars = tyVars;
+		tyVars.beginScope();
 		handleForall( functionType->get_forall() );
 		mutateAll( functionType->get_returnVals(), *this );
@@ -72,13 +72,13 @@
 			} // if
 		} // if
-		tyVars = oldTyVars;
+		tyVars.endScope();
 		return ret;
 	}
 
 	Type * FindFunction::mutate( PointerType *pointerType ) {
-		TyVarMap oldTyVars = tyVars;
+		tyVars.beginScope();
 		handleForall( pointerType->get_forall() );
 		Type *ret = Mutator::mutate( pointerType );
-		tyVars = oldTyVars;
+		tyVars.endScope();
 		return ret;
 	}
