Index: src/GenPoly/DeclMutator.cc
===================================================================
--- src/GenPoly/DeclMutator.cc	(revision 540ddb7d0104114dad454c7e4ba18fbd5d9a1c69)
+++ src/GenPoly/DeclMutator.cc	(revision dbd8652cebff1e6ac5f417592f678108e89c3503)
@@ -24,10 +24,15 @@
 	}
 
-	DeclMutator::DeclMutator() : Mutator(), declsToAdd(1) {}
+	DeclMutator::DeclMutator() : Mutator(), declsToAdd(1), declsToAddAfter(1) {}
 
 	DeclMutator::~DeclMutator() {}
 	
 	void DeclMutator::mutateDeclarationList( std::list< Declaration* > &decls ) {
-		for ( std::list< Declaration* >::iterator decl = decls.begin(); decl != decls.end(); ++decl ) {
+		for ( std::list< Declaration* >::iterator decl = decls.begin(); ; ++decl ) {
+			// splice in new declarations after previous decl
+			decls.splice( decl, declsToAddAfter.back() );
+
+			if ( decl == decls.end() ) break;
+			
 			// run mutator on declaration
 			*decl = maybeMutate( *decl, *this );
@@ -39,6 +44,7 @@
 
 	void DeclMutator::doBeginScope() {
-		// add new decl list for inside of scope
+		// add new decl lists for inside of scope
 		declsToAdd.resize( declsToAdd.size()+1 );
+		declsToAddAfter.resize( declsToAddAfter.size()+1 );
 	}
 
@@ -49,4 +55,9 @@
 		newBack->splice( newBack->end(), *back );
 		declsToAdd.pop_back();
+		
+		back = declsToAddAfter.rbegin();
+		newBack = back + 1;
+		newBack->splice( newBack->end(), *back );
+		declsToAddAfter.pop_back();
 	}
 
@@ -61,5 +72,8 @@
 		stmt = maybeMutate( stmt, *this );
 		// return if no declarations to add
-		if ( declsToAdd.back().empty() ) return stmt;
+		if ( declsToAdd.back().empty() && declsToAddAfter.back().empty() ) {
+			doEndScope();
+			return stmt;
+		}
 
 		// otherwise add declarations to new compound statement
@@ -71,8 +85,15 @@
 		declsToAdd.back().clear();
 
+		// add mutated statement
+		compound->get_kids().push_back( stmt );
+
+		// add declarations after to new compound statement
+		for ( std::list< Declaration* >::iterator decl = declsToAddAfter.back().begin(); decl != declsToAddAfter.back().end(); ++decl ) {
+			DeclStmt *declStmt = new DeclStmt( noLabels, *decl );
+			compound->get_kids().push_back( declStmt );
+		}
+		declsToAddAfter.back().clear();
+
 		doEndScope();
-
-		// add mutated statement and return
-		compound->get_kids().push_back( stmt );
 		return compound;
 	}
@@ -80,6 +101,16 @@
 	void DeclMutator::mutateStatementList( std::list< Statement* > &stmts ) {
 		doBeginScope();
+
 		
-		for ( std::list< Statement* >::iterator stmt = stmts.begin(); stmt != stmts.end(); ++stmt ) {
+		for ( std::list< Statement* >::iterator stmt = stmts.begin(); ; ++stmt ) {
+			// add any new declarations after the previous statement
+			for ( std::list< Declaration* >::iterator decl = declsToAddAfter.back().begin(); decl != declsToAddAfter.back().end(); ++decl ) {
+				DeclStmt *declStmt = new DeclStmt( noLabels, *decl );
+				stmts.insert( stmt, declStmt );
+			}
+			declsToAddAfter.back().clear();
+
+			if ( stmt == stmts.end() ) break;
+			
 			// run mutator on statement
 			*stmt = maybeMutate( *stmt, *this );
@@ -92,5 +123,5 @@
 			declsToAdd.back().clear();
 		}
-
+		
 		doEndScope();
 	}
@@ -98,4 +129,8 @@
 	void DeclMutator::addDeclaration( Declaration *decl ) {
 		declsToAdd.back().push_back( decl );
+	}
+
+	void DeclMutator::addDeclarationAfter( Declaration *decl ) {
+		declsToAddAfter.back().push_back( decl );
 	}
 
Index: src/GenPoly/DeclMutator.h
===================================================================
--- src/GenPoly/DeclMutator.h	(revision 540ddb7d0104114dad454c7e4ba18fbd5d9a1c69)
+++ src/GenPoly/DeclMutator.h	(revision dbd8652cebff1e6ac5f417592f678108e89c3503)
@@ -55,7 +55,11 @@
 		/// Add a declaration to the list to be added before the current position
 		void addDeclaration( Declaration* decl );
+		/// Add a declaration to the list to be added after the current position
+		void addDeclarationAfter( Declaration* decl );
 	private:
 		/// A stack of declarations to add before the current declaration or statement
 		std::vector< std::list< Declaration* > > declsToAdd;
+		/// A stack of declarations to add after the current declaration or statement
+		std::vector< std::list< Declaration* > > declsToAddAfter;
 	};
 } // namespace
