Index: src/GenPoly/PolyMutator.cc
===================================================================
--- src/GenPoly/PolyMutator.cc	(revision 262f085f5bcbf8161e794c370badc1a66ccb3991)
+++ src/GenPoly/PolyMutator.cc	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
@@ -50,4 +50,11 @@
 
 	Statement * PolyMutator::mutateStatement( Statement *stmt ) {
+		// don't want statements from outer CompoundStmts to be added to this CompoundStmt
+		ValueGuard< std::list< Statement* > > oldStmtsToAdd( stmtsToAdd );
+		ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter );
+		ValueGuard< TypeSubstitution * > oldEnv( env );
+		stmtsToAdd.clear();
+		stmtsToAddAfter.clear();
+
 		Statement *newStmt = maybeMutate( stmt, *this );
 		if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) {
@@ -83,33 +90,33 @@
 
 	Statement * PolyMutator::mutate(IfStmt *ifStmt) {
+		ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
 		ifStmt->set_thenPart(  mutateStatement( ifStmt->get_thenPart() ) );
 		ifStmt->set_elsePart(  mutateStatement( ifStmt->get_elsePart() ) );
-		ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
 		return ifStmt;
 	}
 
 	Statement * PolyMutator::mutate(WhileStmt *whileStmt) {
+		whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
 		whileStmt->set_body(  mutateStatement( whileStmt->get_body() ) );
-		whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
 		return whileStmt;
 	}
 
 	Statement * PolyMutator::mutate(ForStmt *forStmt) {
-		forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
 		mutateAll( forStmt->get_initialization(), *this );
 		forStmt->set_condition(  mutateExpression( forStmt->get_condition() ) );
 		forStmt->set_increment(  mutateExpression( forStmt->get_increment() ) );
+		forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
 		return forStmt;
 	}
 
 	Statement * PolyMutator::mutate(SwitchStmt *switchStmt) {
+		switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
 		mutateStatementList( switchStmt->get_statements() );
-		switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
 		return switchStmt;
 	}
 
 	Statement * PolyMutator::mutate(CaseStmt *caseStmt) {
+		caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
 		mutateStatementList( caseStmt->get_statements() );
-		caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
 		return caseStmt;
 	}
