Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision bbbc067e84adc59b31d39e97991980bf6379934a)
+++ src/GenPoly/Box.cc	(revision 2f42718dd1dafad85f808eaefd91c3a4c1871b20)
@@ -286,6 +286,6 @@
 			TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param );
 			std::string paramName = mangleType( &paramType );
-			layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
-			layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
+			layoutFnType->parameters.push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
+			layoutFnType->parameters.push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
 		}
 	}
@@ -367,9 +367,9 @@
 
 		ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
-		layoutFnType->get_parameters().push_back( sizeParam );
+		layoutFnType->parameters.push_back( sizeParam );
 		ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );
-		layoutFnType->get_parameters().push_back( alignParam );
+		layoutFnType->parameters.push_back( alignParam );
 		ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );
-		layoutFnType->get_parameters().push_back( offsetParam );
+		layoutFnType->parameters.push_back( offsetParam );
 		addOtypeParams( layoutFnType, otypeParams );
 
@@ -428,7 +428,7 @@
 
 		ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
-		layoutFnType->get_parameters().push_back( sizeParam );
+		layoutFnType->parameters.push_back( sizeParam );
 		ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );
-		layoutFnType->get_parameters().push_back( alignParam );
+		layoutFnType->parameters.push_back( alignParam );
 		addOtypeParams( layoutFnType, otypeParams );
 
@@ -468,6 +468,6 @@
 			// to take those polymorphic types as pointers. Therefore, there can be two different functions
 			// with the same mangled name, so we need to further mangle the names.
-			for ( std::list< DeclarationWithType *>::iterator retval = function->get_returnVals().begin(); retval != function->get_returnVals().end(); ++retval ) {
-				if ( isPolyType( (*retval)->get_type(), tyVars ) ) {
+			for ( auto retval : function->returnVals ) {
+				if ( isPolyType( retval->get_type(), tyVars ) ) {
 					name << "P";
 				} else {
@@ -476,7 +476,7 @@
 			}
 			name << "_";
-			std::list< DeclarationWithType *> &paramList = function->get_parameters();
-			for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
-				if ( isPolyType( (*arg)->get_type(), tyVars ) ) {
+			auto & paramList = function->parameters;
+			for ( auto arg : paramList ) {
+				if ( isPolyType( arg->get_type(), tyVars ) ) {
 					name << "P";
 				} else {
@@ -518,20 +518,20 @@
 				makeTyVarMap( functionType, scopeTyVars );
 
-				std::list< DeclarationWithType *> &paramList = functionType->parameters;
-				std::list< FunctionType *> functions;
-				for ( Type::ForallList::iterator tyVar = functionType->forall.begin(); tyVar != functionType->forall.end(); ++tyVar ) {
-					for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->assertions.begin(); assert != (*tyVar)->assertions.end(); ++assert ) {
-						findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
+				auto & paramList = functionType->parameters;
+				std::vector< FunctionType *> functions;
+				for ( auto tyVar : functionType->forall ) {
+					for ( auto assert : tyVar->assertions ) {
+						findFunction( assert->get_type(), functions, scopeTyVars, needsAdapter );
 					} // for
 				} // for
-				for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
-					findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter );
+				for ( auto arg : paramList ) {
+					findFunction( arg->get_type(), functions, scopeTyVars, needsAdapter );
 				} // for
 
-				for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
-					std::string mangleName = mangleAdapterName( *funType, scopeTyVars );
+				for ( auto funType : functions ) {
+					std::string mangleName = mangleAdapterName( funType, scopeTyVars );
 					if ( adapters.find( mangleName ) == adapters.end() ) {
 						std::string adapterName = makeAdapterName( mangleName );
-						adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) );
+						adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( funType, scopeTyVars ) ), nullptr ) ) );
 					} // if
 				} // for
@@ -612,5 +612,5 @@
 			assert( funcType );
 
-			std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin();
+			std::vector< DeclarationWithType* >::const_iterator fnParm = funcType->parameters.begin();
 			std::list< Expression* >::const_iterator fnArg = arg;
 			std::set< std::string > seenTypes; ///< names for generic types we've seen
@@ -624,5 +624,5 @@
 
 			// add type information args for presently unseen types in parameter list
-			for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
+			for ( ; fnParm != funcType->parameters.end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
 				if ( ! (*fnArg)->get_result() ) continue;
 				Type * argType = (*fnArg)->get_result();
@@ -708,5 +708,5 @@
 //			if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
 			if ( isDynRet( function, tyVars ) ) {
-				ret = addRetParam( appExpr, function->get_returnVals().front()->get_type(), arg );
+				ret = addRetParam( appExpr, function->returnVals.front()->get_type(), arg );
 			} // if
 			std::string mangleName = mangleAdapterName( function, tyVars );
@@ -786,9 +786,10 @@
 		}
 
-		void Pass1::boxParams( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
-			for ( std::list< DeclarationWithType *>::const_iterator param = function->get_parameters().begin(); param != function->parameters.end(); ++param, ++arg ) {
-				assertf( arg != appExpr->args.end(), "boxParams: missing argument for param %s to %s in %s", toString( *param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() );
-				addCast( *arg, (*param)->get_type(), exprTyVars );
-				boxParam( (*param)->get_type(), *arg, exprTyVars );
+		void Pass1::boxParams( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator & arg, const TyVarMap &exprTyVars ) {
+			for ( auto param : function->parameters ) {
+				assertf( arg != appExpr->args.end(), "boxParams: missing argument for param %s to %s in %s", toString( param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() );
+				addCast( *arg, param->get_type(), exprTyVars );
+				boxParam( param->get_type(), *arg, exprTyVars );
+				++arg;
 			} // for
 		}
@@ -796,11 +797,11 @@
 		void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
 			std::list< Expression *>::iterator cur = arg;
-			for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
-				for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->assertions.begin(); assert != (*tyVar)->assertions.end(); ++assert ) {
-					InferredParams::const_iterator inferParam = appExpr->inferParams.find( (*assert)->get_uniqueId() );
-					assertf( inferParam != appExpr->inferParams.end(), "addInferredParams missing inferred parameter: %s in: %s", toString( *assert ).c_str(), toString( appExpr ).c_str() );
+			for ( auto tyVar : functionType->forall ) {
+				for ( auto assert : tyVar->assertions ) {
+					InferredParams::const_iterator inferParam = appExpr->inferParams.find( assert->get_uniqueId() );
+					assertf( inferParam != appExpr->inferParams.end(), "addInferredParams missing inferred parameter: %s in: %s", toString( assert ).c_str(), toString( appExpr ).c_str() );
 					Expression *newExpr = inferParam->second.expr->clone();
-					addCast( newExpr, (*assert)->get_type(), tyVars );
-					boxParam( (*assert)->get_type(), newExpr, tyVars );
+					addCast( newExpr, assert->get_type(), tyVars );
+					boxParam( assert->get_type(), newExpr, tyVars );
 					appExpr->get_args().insert( cur, newExpr );
 				} // for
@@ -813,8 +814,8 @@
 			// make a new parameter that is a pointer to the type of the old return value
 			retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) );
-			funcType->get_parameters().push_front( retParm );
+			funcType->parameters.insert( funcType->parameters.begin(), retParm );
 
 			// we don't need the return value any more
-			funcType->get_returnVals().clear();
+			funcType->returnVals.clear();
 		}
 
@@ -825,5 +826,5 @@
 				makeRetParm( adapter );
 			} // if
-			adapter->get_parameters().push_front( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) );
+			adapter->parameters.insert( adapter->parameters.begin(), new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) );
 			return adapter;
 		}
@@ -844,5 +845,5 @@
 		}
 
-		void addAdapterParams( ApplicationExpr *adapteeApp, std::list< DeclarationWithType *>::iterator arg, std::list< DeclarationWithType *>::iterator param, std::list< DeclarationWithType *>::iterator paramEnd, std::list< DeclarationWithType *>::iterator realParam, const TyVarMap &tyVars ) {
+		void addAdapterParams( ApplicationExpr *adapteeApp, std::vector< DeclarationWithType *>::iterator arg, std::vector< DeclarationWithType *>::iterator param, std::vector< DeclarationWithType *>::iterator paramEnd, std::vector< DeclarationWithType *>::iterator realParam, const TyVarMap &tyVars ) {
 			UniqueName paramNamer( "_p" );
 			for ( ; param != paramEnd; ++param, ++arg, ++realParam ) {
@@ -858,5 +859,5 @@
 			FunctionType *adapterType = makeAdapterType( adaptee, tyVars );
 			adapterType = ScrubTyVars::scrub( adapterType, tyVars );
-			DeclarationWithType *adapteeDecl = adapterType->get_parameters().front();
+			DeclarationWithType *adapteeDecl = adapterType->parameters.front();
 			adapteeDecl->set_name( "_adaptee" );
 			// do not carry over attributes to real type parameters/return values
@@ -877,22 +878,22 @@
 			for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
 				assert( tyArg != realType->get_forall().end() );
-				std::list< DeclarationWithType *>::iterator assertArg = (*tyArg)->get_assertions().begin();
-				std::list< DeclarationWithType *>::iterator assertParam = (*tyParam)->get_assertions().begin();
-				std::list< DeclarationWithType *>::iterator realAssertParam = (*realTyParam)->get_assertions().begin();
-				for ( ; assertParam != (*tyParam)->get_assertions().end(); ++assertArg, ++assertParam, ++realAssertParam ) {
-					assert( assertArg != (*tyArg)->get_assertions().end() );
+				std::vector< DeclarationWithType *>::iterator assertArg = (*tyArg)->assertions.begin();
+				std::vector< DeclarationWithType *>::iterator assertParam = (*tyParam)->assertions.begin();
+				std::vector< DeclarationWithType *>::iterator realAssertParam = (*realTyParam)->assertions.begin();
+				for ( ; assertParam != (*tyParam)->assertions.end(); ++assertArg, ++assertParam, ++realAssertParam ) {
+					assert( assertArg != (*tyArg)->assertions.end() );
 					adapteeApp->get_args().push_back( makeAdapterArg( *assertParam, *assertArg, *realAssertParam, tyVars ) );
 				} // for
 			} // for
 
-			std::list< DeclarationWithType *>::iterator arg = realType->get_parameters().begin();
-			std::list< DeclarationWithType *>::iterator param = adapterType->get_parameters().begin();
-			std::list< DeclarationWithType *>::iterator realParam = adaptee->get_parameters().begin();
+			std::vector< DeclarationWithType *>::iterator arg = realType->parameters.begin();
+			std::vector< DeclarationWithType *>::iterator param = adapterType->parameters.begin();
+			std::vector< DeclarationWithType *>::iterator realParam = adaptee->parameters.begin();
 			param++;		// skip adaptee parameter in the adapter type
-			if ( realType->get_returnVals().empty() ) {
+			if ( realType->returnVals.empty() ) {
 				// void return
-				addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
+				addAdapterParams( adapteeApp, arg, param, adapterType->parameters.end(), realParam, tyVars );
 				bodyStmt = new ExprStmt( adapteeApp );
-			} else if ( isDynType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
+			} else if ( isDynType( adaptee->returnVals.front()->get_type(), tyVars ) ) {
 				// return type T
 				if ( (*param)->get_name() == "" ) {
@@ -901,12 +902,12 @@
 				} // if
 				UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
-				UntypedExpr *deref = UntypedExpr::createDeref( new CastExpr( new VariableExpr( *param++ ), new PointerType( Type::Qualifiers(), realType->get_returnVals().front()->get_type()->clone() ) ) );
+				UntypedExpr *deref = UntypedExpr::createDeref( new CastExpr( new VariableExpr( *param++ ), new PointerType( Type::Qualifiers(), realType->returnVals.front()->get_type()->clone() ) ) );
 				assign->get_args().push_back( deref );
-				addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
+				addAdapterParams( adapteeApp, arg, param, adapterType->parameters.end(), realParam, tyVars );
 				assign->get_args().push_back( adapteeApp );
 				bodyStmt = new ExprStmt( assign );
 			} else {
 				// adapter for a function that returns a monomorphic value
-				addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
+				addAdapterParams( adapteeApp, arg, param, adapterType->parameters.end(), realParam, tyVars );
 				bodyStmt = new ReturnStmt( adapteeApp );
 			} // if
@@ -919,13 +920,13 @@
 		void Pass1::passAdapters( ApplicationExpr * appExpr, FunctionType * functionType, const TyVarMap & exprTyVars ) {
 			// collect a list of function types passed as parameters or implicit parameters (assertions)
-			std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
-			std::list< FunctionType *> functions;
-			for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
-				for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
-					findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter );
+			auto & paramList = functionType->parameters;
+			std::vector< FunctionType *> functions;
+			for ( auto tyVar : functionType->forall ) {
+				for ( auto assert : tyVar->assertions ) {
+					findFunction( assert->get_type(), functions, exprTyVars, needsAdapter );
 				} // for
 			} // for
-			for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
-				findFunction( (*arg)->get_type(), functions, exprTyVars, needsAdapter );
+			for ( auto arg : paramList ) {
+				findFunction( arg->get_type(), functions, exprTyVars, needsAdapter );
 			} // for
 
@@ -934,7 +935,7 @@
 			std::set< std::string > adaptersDone;
 
-			for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
-				FunctionType *originalFunction = (*funType)->clone();
-				FunctionType *realFunction = (*funType)->clone();
+			for ( auto funType : functions ) {
+				FunctionType * originalFunction = funType->clone();
+				FunctionType * realFunction = funType->clone();
 				std::string mangleName = SymTab::Mangler::mangle( realFunction );
 
@@ -954,5 +955,5 @@
 					if ( adapter == adapters.end() ) {
 						// adapter has not been created yet in the current scope, so define it
-						FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars );
+						FunctionDecl *newAdapter = makeAdapter( funType, realFunction, mangleName, exprTyVars );
 						std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) );
 						adapter = answer.first;
@@ -1255,22 +1256,21 @@
 
 		void Pass2::addAdapters( FunctionType *functionType ) {
-			std::list< DeclarationWithType *> &paramList = functionType->parameters;
-			std::list< FunctionType *> functions;
-			for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) {
-				Type *orig = (*arg)->get_type();
+			auto & paramList = functionType->parameters;
+			std::vector< FunctionType *> functions;
+			for ( auto arg : paramList ) {
+				Type *orig = arg->get_type();
 				findAndReplaceFunction( orig, functions, scopeTyVars, needsAdapter );
-				(*arg)->set_type( orig );
+				arg->set_type( orig );
 			}
 			std::set< std::string > adaptersDone;
-			for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
-				std::string mangleName = mangleAdapterName( *funType, scopeTyVars );
+			for ( auto funType : functions ) {
+				std::string mangleName = mangleAdapterName( funType, scopeTyVars );
 				if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
 					std::string adapterName = makeAdapterName( mangleName );
 					// adapter may not be used in body, pass along with unused attribute.
-					paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) );
+					paramList.insert( paramList.begin(), new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) );
 					adaptersDone.insert( adaptersDone.begin(), mangleName );
 				}
 			}
-//  deleteAll( functions );
 		}
 
@@ -1324,4 +1324,23 @@
 
 		void Pass2::premutate( FunctionType *funcType ) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 			GuardScope( scopeTyVars );
 			makeTyVarMap( funcType, scopeTyVars );
@@ -1329,14 +1348,21 @@
 			// move polymorphic return type to parameter list
 			if ( isDynRet( funcType ) ) {
-				ObjectDecl *ret = strict_dynamic_cast< ObjectDecl* >( funcType->get_returnVals().front() );
+				ObjectDecl *ret = strict_dynamic_cast< ObjectDecl* >( funcType->returnVals.front() );
 				ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
-				funcType->get_parameters().push_front( ret );
-				funcType->get_returnVals().pop_front();
+				funcType->parameters.insert( funcType->parameters.begin(), ret );
+				funcType->returnVals.erase(funcType->returnVals.begin());
 				ret->set_init( nullptr ); // xxx - memory leak?
 			}
 
-			// add size/align and assertions for type parameters to parameter list
-			std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
-			std::list< DeclarationWithType *> inferredParams;
+			// create a list of parameters after adding new ones
+			std::vector<DeclarationWithType *> newParams;
+			std::vector<DeclarationWithType *> inferredParams;
+
+			// reserve some memory for these vectors
+			// Number of elements needed should be somewhat linear with the number of parameters / forall
+			// "somewhat linear" == 2X
+			newParams.reserve(funcType->parameters.size() * 2 + funcType->forall.size() * 2);
+			inferredParams.reserve(funcType->forall.size() * 2);
+
 			// size/align/offset parameters may not be used in body, pass along with unused attribute.
 			ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
@@ -1344,56 +1370,50 @@
 			ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
 			                   new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
-			for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
-				ObjectDecl *sizeParm, *alignParm;
+
+			// We do this several time, create a functor for it
+			auto pushObj = [&newObj, &newParams]( const std::string & name ) {
+				auto parm = newObj.clone();
+				parm->set_name( name );
+				newParams.push_back( parm );
+			};
+
+			// add size/align and assertions for type parameters to parameter list
+			for ( auto tyParm : funcType->forall ) {
 				// add all size and alignment parameters to parameter list
-				if ( (*tyParm)->isComplete() ) {
-					TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
+				if ( tyParm->isComplete() ) {
+					TypeInstType parmType( Type::Qualifiers(), tyParm->get_name(), tyParm );
 					std::string parmName = mangleType( &parmType );
-
-					sizeParm = newObj.clone();
-					sizeParm->set_name( sizeofName( parmName ) );
-					last = funcType->get_parameters().insert( last, sizeParm );
-					++last;
-
-					alignParm = newObj.clone();
-					alignParm->set_name( alignofName( parmName ) );
-					last = funcType->get_parameters().insert( last, alignParm );
-					++last;
+					pushObj( sizeofName( parmName ) );
+					pushObj( alignofName( parmName ) );
 				}
 				// move all assertions into parameter list
-				for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
+				// move all assertions into parameter list
+				for ( auto assert : tyParm->assertions ) {
 					// assertion parameters may not be used in body, pass along with unused attribute.
-					(*assert)->get_attributes().push_back( new Attribute( "unused" ) );
-					inferredParams.push_back( *assert );
-				}
-				(*tyParm)->get_assertions().clear();
+					assert->attributes.push_back( new Attribute( "unused" ) );
+					inferredParams.push_back( assert );
+				}
+				tyParm->assertions.clear();
 			}
 
 			// add size/align for generic parameter types to parameter list
 			std::set< std::string > seenTypes; // sizeofName for generic types we've seen
-			for ( std::list< DeclarationWithType* >::const_iterator fnParm = last; fnParm != funcType->get_parameters().end(); ++fnParm ) {
-				Type *polyType = isPolyType( (*fnParm)->get_type(), scopeTyVars );
-				if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
+			for ( DeclarationWithType * fnParm : funcType->parameters )
+			{
+				Type *polyType = isPolyType( fnParm->get_type(), scopeTyVars );
+				if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) )
+				{
 					std::string typeName = mangleType( polyType );
 					if ( seenTypes.count( typeName ) ) continue;
 
-					ObjectDecl *sizeParm, *alignParm, *offsetParm;
-					sizeParm = newObj.clone();
-					sizeParm->set_name( sizeofName( typeName ) );
-					last = funcType->get_parameters().insert( last, sizeParm );
-					++last;
-
-					alignParm = newObj.clone();
-					alignParm->set_name( alignofName( typeName ) );
-					last = funcType->get_parameters().insert( last, alignParm );
-					++last;
+					pushObj( sizeofName ( typeName ) );
+					pushObj( alignofName( typeName ) );
 
 					if ( StructInstType *polyBaseStruct = dynamic_cast< StructInstType* >( polyType ) ) {
 						// NOTE zero-length arrays are illegal in C, so empty structs have no offset array
 						if ( ! polyBaseStruct->get_baseStruct()->get_members().empty() ) {
-							offsetParm = newPtr.clone();
-							offsetParm->set_name( offsetofName( typeName ) );
-							last = funcType->get_parameters().insert( last, offsetParm );
-							++last;
+							auto offset = newPtr.clone();
+							offset->set_name( offsetofName( typeName ) );
+							newParams.push_back( offset );
 						}
 					}
@@ -1403,5 +1423,9 @@
 
 			// splice assertion parameters into parameter list
-			funcType->get_parameters().splice( last, inferredParams );
+			std::copy( inferredParams      , std::back_inserter(newParams) );
+			std::copy( funcType->parameters, std::back_inserter(newParams) );
+
+			funcType->parameters.swap(newParams);
+
 			addAdapters( funcType );
 		}
@@ -1470,7 +1494,7 @@
 
 			// make sure that any type information passed into the function is accounted for
-			for ( std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin(); fnParm != funcType->get_parameters().end(); ++fnParm ) {
+			for ( auto fnParm : funcType->parameters ) {
 				// condition here duplicates that in Pass2::mutate( FunctionType* )
-				Type *polyType = isPolyType( (*fnParm)->get_type(), scopeTyVars );
+				Type *polyType = isPolyType( fnParm->get_type(), scopeTyVars );
 				if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
 					knownLayouts.insert( mangleType( polyType ) );
Index: src/GenPoly/FindFunction.cc
===================================================================
--- src/GenPoly/FindFunction.cc	(revision bbbc067e84adc59b31d39e97991980bf6379934a)
+++ src/GenPoly/FindFunction.cc	(revision 2f42718dd1dafad85f808eaefd91c3a4c1871b20)
@@ -29,5 +29,5 @@
 	class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting {
 	  public:
-		FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
+		FindFunction( std::vector< FunctionType* > & functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
 
 		void premutate( FunctionType * functionType );
@@ -37,5 +37,5 @@
 		void handleForall( const Type::ForallList &forall );
 
-		std::list< FunctionType* > &functions;
+		std::vector< FunctionType* > &functions;
 		TyVarMap tyVars;
 		bool replaceMode;
@@ -43,15 +43,15 @@
 	};
 
-	void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
+	void findFunction( Type *type, std::vector< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
 		PassVisitor<FindFunction> finder( functions, tyVars, false, predicate );
 		type->acceptMutator( finder );
 	}
 
-	void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
+	void findAndReplaceFunction( Type *&type, std::vector< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
 		PassVisitor<FindFunction> finder( functions, tyVars, true, predicate );
 		type = type->acceptMutator( finder );
 	}
 
-	FindFunction::FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate )
+	FindFunction::FindFunction( std::vector< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate )
 		: functions( functions ), tyVars( tyVars ), replaceMode( replaceMode ), predicate( predicate ) {
 	}
@@ -70,5 +70,5 @@
 		GuardScope( tyVars );
 		handleForall( functionType->get_forall() );
-		mutateAll( functionType->get_returnVals(), *visitor );
+		mutateAll( functionType->returnVals, *visitor );
 	}
 
Index: src/GenPoly/FindFunction.h
===================================================================
--- src/GenPoly/FindFunction.h	(revision bbbc067e84adc59b31d39e97991980bf6379934a)
+++ src/GenPoly/FindFunction.h	(revision 2f42718dd1dafad85f808eaefd91c3a4c1871b20)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// FindFunction.h -- 
+// FindFunction.h --
 //
 // Author           : Richard C. Bilson
@@ -27,7 +27,7 @@
 
 	/// recursively walk `type`, placing all functions that match `predicate` under `tyVars` into `functions`
-	void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate );
+	void findFunction( Type *type, std::vector< FunctionType* > & functions, const TyVarMap &tyVars, FindFunctionPredicate predicate );
 	/// like `findFunction`, but also replaces the function type with void ()(void)
-	void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate );
+	void findAndReplaceFunction( Type *&type, std::vector< FunctionType* > & functions, const TyVarMap &tyVars, FindFunctionPredicate predicate );
 } // namespace GenPoly
 
Index: src/GenPoly/GenPoly.cc
===================================================================
--- src/GenPoly/GenPoly.cc	(revision bbbc067e84adc59b31d39e97991980bf6379934a)
+++ src/GenPoly/GenPoly.cc	(revision 2f42718dd1dafad85f808eaefd91c3a4c1871b20)
@@ -144,26 +144,22 @@
 
 	ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) {
-		if ( function->get_returnVals().empty() ) return 0;
-
-		return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
+		if ( function->returnVals.empty() ) return 0;
+
+		return (ReferenceToType*)isDynType( function->returnVals.front()->get_type(), forallTypes );
 	}
 
 	ReferenceToType *isDynRet( FunctionType *function ) {
-		if ( function->get_returnVals().empty() ) return 0;
+		if ( function->returnVals.empty() ) return 0;
 
 		TyVarMap forallTypes( TypeDecl::Data{} );
 		makeTyVarMap( function, forallTypes );
-		return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
+		return (ReferenceToType*)isDynType( function->returnVals.front()->get_type(), forallTypes );
 	}
 
 	bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {
-// 		if ( ! adaptee->get_returnVals().empty() && isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
-// 			return true;
-// 		} // if
 		if ( isDynRet( adaptee, tyVars ) ) return true;
 
-		for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
-// 			if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {
-			if ( isDynType( (*innerArg)->get_type(), tyVars ) ) {
+		for ( auto innerArg : adaptee->parameters ) {
+			if ( isDynType( innerArg->get_type(), tyVars ) ) {
 				return true;
 			} // if
@@ -315,5 +311,5 @@
 		/// Flattens a declaration list
 		template<typename Output>
-		void flattenList( list< DeclarationWithType* > src, Output out ) {
+		void flattenList( vector< DeclarationWithType* > src, Output out ) {
 			for ( DeclarationWithType* decl : src ) {
 				ResolvExpr::flatten( decl->get_type(), out );
@@ -323,5 +319,5 @@
 		/// Flattens a list of types
 		template<typename Output>
-		void flattenList( list< Type* > src, Output out ) {
+		void flattenList( vector< Type* > src, Output out ) {
 			for ( Type* ty : src ) {
 				ResolvExpr::flatten( ty, out );
@@ -395,11 +391,11 @@
 
 			vector<Type*> aparams, bparams;
-			flattenList( af->get_parameters(), back_inserter( aparams ) );
-			flattenList( bf->get_parameters(), back_inserter( bparams ) );
+			flattenList( af->parameters, back_inserter( aparams ) );
+			flattenList( bf->parameters, back_inserter( bparams ) );
 			if ( aparams.size() != bparams.size() ) return false;
 
 			vector<Type*> areturns, breturns;
-			flattenList( af->get_returnVals(), back_inserter( areturns ) );
-			flattenList( bf->get_returnVals(), back_inserter( breturns ) );
+			flattenList( af->returnVals, back_inserter( areturns ) );
+			flattenList( bf->returnVals, back_inserter( breturns ) );
 			if ( areturns.size() != breturns.size() ) return false;
 
@@ -429,6 +425,6 @@
 
 			vector<Type*> atypes, btypes;
-			flattenList( at->get_types(), back_inserter( atypes ) );
-			flattenList( bt->get_types(), back_inserter( btypes ) );
+			flattenList( at->types, back_inserter( atypes ) );
+			flattenList( bt->types, back_inserter( btypes ) );
 			if ( atypes.size() != btypes.size() ) return false;
 
Index: src/GenPoly/Specialize.cc
===================================================================
--- src/GenPoly/Specialize.cc	(revision bbbc067e84adc59b31d39e97991980bf6379934a)
+++ src/GenPoly/Specialize.cc	(revision 2f42718dd1dafad85f808eaefd91c3a4c1871b20)
@@ -91,5 +91,5 @@
 		if ( tuple1 && tuple2 ) {
 			if ( tuple1->size() != tuple2->size() ) return false;
-			for ( auto types : group_iterate( tuple1->get_types(), tuple2->get_types() ) ) {
+			for ( auto types : group_iterate( tuple1->types, tuple2->types ) ) {
 				if ( ! matchingTupleStructure( std::get<0>( types ), std::get<1>( types ) ) ) return false;
 			}
@@ -115,5 +115,5 @@
 	size_t functionParameterSize( FunctionType * ftype ) {
 		size_t sz = 0;
-		for ( DeclarationWithType * p : ftype->get_parameters() ) {
+		for ( DeclarationWithType * p : ftype->parameters ) {
 			sz += singleParameterSize( p->get_type() );
 		}
@@ -227,9 +227,9 @@
 		}
 		std::unique_ptr< FunctionType > actualTypeManager( actualType ); // for RAII
-		std::list< DeclarationWithType * >::iterator actualBegin = actualType->get_parameters().begin();
-		std::list< DeclarationWithType * >::iterator actualEnd = actualType->get_parameters().end();
+		auto actualBegin = actualType->parameters.begin();
+		auto actualEnd   = actualType->parameters.end();
 
 		std::list< Expression * > args;
-		for ( DeclarationWithType* param : thunkFunc->get_functionType()->get_parameters() ) {
+		for ( DeclarationWithType* param : thunkFunc->get_functionType()->parameters ) {
 			// name each thunk parameter and explode it - these are then threaded back into the actual function call.
 			param->set_name( paramNamer.newName() );
@@ -281,7 +281,7 @@
 		FunctionType *function = getFunctionType( appExpr->function->result );
 		assert( function );
-		std::list< DeclarationWithType* >::iterator formal;
+		std::vector< DeclarationWithType* >::iterator formal;
 		std::list< Expression* >::iterator actual;
-		for ( formal = function->get_parameters().begin(), actual = appExpr->get_args().begin(); formal != function->get_parameters().end() && actual != appExpr->get_args().end(); ++formal, ++actual ) {
+		for ( formal = function->parameters.begin(), actual = appExpr->get_args().begin(); formal != function->parameters.end() && actual != appExpr->get_args().end(); ++formal, ++actual ) {
 			*actual = doSpecialization( (*formal)->get_type(), *actual, &appExpr->inferParams );
 		}
