Index: cpp/f8-to-f1/conv_f8tof1.cpp
===================================================================
--- cpp/f8-to-f1/conv_f8tof1.cpp	(revision 23)
+++ cpp/f8-to-f1/conv_f8tof1.cpp	(revision 24)
@@ -189,7 +189,9 @@
 		 prodIter != this->productions.end(); prodIter++) {
 		vector<SubProduction> *subproductions = &(prodIter->second->subproductions);
-		for (int i = 0; i < subproductions->size(); i++) {
-			if (subproductions->at(i).actions.size() == 0) {
-				subproductions->erase(subproductions->begin() + i);
+		for (vector<SubProduction>::iterator i = subproductions->begin(); i != subproductions->end(); /*nothing*/) {
+			if ((*i).actions.size() == 0) {
+				i = subproductions->erase(i);
+			} else {
+				i++;
 			}
 		}
@@ -213,12 +215,17 @@
 			 subProdIter != subproductions->end(); subProdIter++) {
 			SubProduction *sp = &(*subProdIter);
-			for (int actionIter = 0; actionIter < sp->actions.size(); actionIter++) {
-				ActionStrP *actionstrp = &(sp->actions.at(actionIter));
-				if (actionstrp->action != NULL) {
+			for (vector<ActionStrP>::iterator actionIter = sp->actions.begin(); 
+				 actionIter != sp->actions.end(); /*nothing*/) {
+				bool deleted = false;
+				if ((*actionIter).action != NULL) {
 					vector<SString>::iterator result = find(emptyProductionNames.begin(), emptyProductionNames.end(), 
-															actionstrp->action->name);
+															(*actionIter).action->name);
 					if (result != emptyProductionNames.end()) { //emptyProductionNames contains the action name
-						sp->actions.erase(sp->actions.begin() + actionIter);
-					}
+						actionIter = sp->actions.erase(actionIter);
+						deleted = true;
+					}
+				}
+				if (!deleted) {
+					actionIter++;
 				}
 			}
@@ -702,7 +709,10 @@
 			 subProdIter != prodIter->second->subproductions.end(); subProdIter++) {
 			SubProduction subProduction = *subProdIter;
-			for (int i = 0; i < subProduction.actions.size(); i++) {
-				if (subProduction.actions.at(i).action == NULL) {
-					subProduction.actions.erase(subProduction.actions.begin() + i);
+			for (vector<ActionStrP>::iterator i = subProduction.actions.begin();
+				 i != subProduction.actions.end(); /*nothing*/) {
+				if ((*i).action == NULL) {
+					i = subProduction.actions.erase(i);
+				} else {
+					i++;
 				}
 			}
Index: cpp/f8-to-f1/geno_f8.cpp
===================================================================
--- cpp/f8-to-f1/geno_f8.cpp	(revision 23)
+++ cpp/f8-to-f1/geno_f8.cpp	(revision 24)
@@ -774,8 +774,10 @@
 		for (vector<SubProduction>::iterator subProdIter = randomProduction->subproductions.begin();
 				subProdIter != randomProduction->subproductions.end(); subProdIter++) {
-			for (int condIter = 0; condIter < (*subProdIter).conditions.size(); condIter++) {
-				Condition c = (*subProdIter).conditions[condIter];
-				if (c.parameter == paramName) {
-					(*subProdIter).conditions.erase((*subProdIter).conditions.begin() + condIter);
+			for (vector<Condition>::iterator condIter = (*subProdIter).conditions.begin(); 
+				 condIter != (*subProdIter).conditions.end(); /*nothing*/) {
+				if ((*condIter).parameter == paramName) {
+					condIter = (*subProdIter).conditions.erase(condIter);
+				} else {
+					condIter++;
 				}
 			}
@@ -798,10 +800,10 @@
 			    	subProdIter != subproductions->end(); subProdIter++) {
 				SubProduction *sp = &(*subProdIter);
-				for (int actionIter = 0; actionIter < sp->actions.size(); actionIter++) {
-					ActionStrP *actionstrp = &(sp->actions.at(actionIter));
-					if (actionstrp->action != NULL) {
-						if (actionstrp->action->name == prodName && actionstrp->params.size() > paramIndex - 1) {
+				for (vector<ActionStrP>::iterator actionIter = sp->actions.begin(); 
+					 actionIter != sp->actions.end(); actionIter++) {
+					if ((*actionIter).action != NULL) {
+						if ((*actionIter).action->name == prodName && (*actionIter).params.size() > paramIndex - 1) {
 							change += paramName.len(); //more less
-							actionstrp->params.erase(actionstrp->params.begin() + (paramIndex - 1));
+							(*actionIter).params.erase((*actionIter).params.begin() + (paramIndex - 1));
 						}
 					}
@@ -1136,9 +1138,11 @@
 			
 			//actions
-			for (int i = 0; i < (*subprodIter).actions.size(); i++) {
-				if ((*subprodIter).actions.at(i).action == NULL) {
+			for (vector<ActionStrP>::iterator i = (*subprodIter).actions.begin(); 
+				 i != (*subprodIter).actions.end(); /*nothing*/) {
+				bool deleted = false;
+				if ((*i).action == NULL) {
 					continue;
 				}
-				SString &actionName = (*subprodIter).actions.at(i).action->name;
+				SString &actionName = (*i).action->name;
 				if (actionName[0] == 'n') {
 					if (paramNames.size() > 0) {
@@ -1147,21 +1151,26 @@
 						if (searchIter != paramNames.end()) { //valid name
 							//ensure it is linked to the correct production
-							(*subprodIter).actions.at(i).action = newLsystem->getParamProduction(actionName);
+							(*i).action = newLsystem->getParamProduction(actionName);
 						} else {
 							//link to random parameter prodution
 							SString name = paramNames[randomN(paramNames.size())];
-							(*subprodIter).actions.at(i).action = newLsystem->getParamProduction(name);
+							(*i).action = newLsystem->getParamProduction(name);
 						}
 					} else { //no params, so delete this param production
-						(*subprodIter).actions.erase((*subprodIter).actions.begin() + i);
+						i = (*subprodIter).actions.erase(i);
+						deleted = true;
 					}
 				} else if (actionName[0] == 'P') {
 					if (newLsystem->productions.find(sstringToString(actionName)) != newLsystem->productions.end()) {
 						//ensure it is linked to the correct production
-						(*subprodIter).actions.at(i).action = newLsystem->productions[sstringToString(actionName)];
+						(*i).action = newLsystem->productions[sstringToString(actionName)];
 					} else {
 						//delete this action
-						(*subprodIter).actions.erase((*subprodIter).actions.begin() + i);
+						i = (*subprodIter).actions.erase(i);
+						deleted = true;
 					}
+				}
+				if (!deleted) {
+					i++;
 				}
 			}
