Index: /cpp/f8-to-f1/geno_f8.cpp
===================================================================
--- /cpp/f8-to-f1/geno_f8.cpp	(revision 9)
+++ /cpp/f8-to-f1/geno_f8.cpp	(revision 10)
@@ -412,5 +412,12 @@
 	
 	Production *p = prodIter->second;
-	SubProduction *sp = &(p->subproductions.at(randomN(p->subproductions.size())));
+	SubProduction *sp;
+	if (p->subproductions.size() > 0) {
+		sp = &(p->subproductions.at(randomN(p->subproductions.size())));
+	} else {
+		mutated += in;
+		chg = -1.0;
+		return mutated;
+	}
 	
 	int commandsToInsert = /*randomN(3) +*/ 1;
@@ -418,5 +425,11 @@
 	for (int i = 0; i < commandsToInsert; i++) {
 		ActionStrP a;
-		a.action = actions.at(randomN(actions.size()));
+		if (actions.size() > 0) {
+			a.action = actions.at(randomN(actions.size()));
+		} else {
+			mutated += in;
+			chg = -1.0;
+			return mutated;
+		}
 		insertLen += a.action->getF8Representation().len();
 		if (a.action->ignoreParams == false && a.action->name[0] == 'P') {
@@ -453,5 +466,5 @@
 	
 	Lsystem *lsystem = this->converter->createLsystem(in);
-	if (lsystem == NULL) {
+	if (lsystem == NULL || lsystem->productions.size() == 0) {
 		mutated += in;
 		chg = -1.0;
@@ -476,6 +489,20 @@
 			}
 			
-			SubProduction *subproduction = &(prodIter->second->subproductions[randomN(prodIter->second->subproductions.size())]);
-			int firstActionIdx = randomN(subproduction->actions.size());
+			SubProduction *subproduction;
+			if (prodIter->second->subproductions.size() > 0) {
+				subproduction = &(prodIter->second->subproductions[randomN(prodIter->second->subproductions.size())]);
+			} else {
+				mutated += in;
+				chg = -1.0;
+				return mutated;
+			}
+			int firstActionIdx;
+			if (subproduction->actions.size() > 0) {
+				firstActionIdx = randomN(subproduction->actions.size());
+			} else {
+				mutated += in;
+				chg = -1.0;
+				return mutated;
+			}
 			int i;
 			vector<ActionStrP> newActions;
@@ -555,5 +582,5 @@
 		int random1 = randomN(interestingSubproductions.size());
 		SubProduction *randomSubproduction = interestingSubproductions[random1];
-		int random2 = randomN(randomSubproduction->conditions.size());
+		int random2 = randomN(randomSubproduction->conditions.size()); //all interesting conditions have conditions.size() > 0
 		Condition *c = &(randomSubproduction->conditions.at(random2));
 		c->relation = this->getDifferentCondition(c->relation);
@@ -572,5 +599,5 @@
 	
 	Lsystem *lsystem = this->converter->createLsystem(in);
-	if (lsystem == NULL) {
+	if (lsystem == NULL || lsystem->productions.size() == 0) {
 		mutated += in;
 		chg = -1.0;
@@ -1094,12 +1121,16 @@
 			 subprodIter != prodIter->second->subproductions.end(); subprodIter++) {
 			//conditions
-			for (vector<Condition>::iterator condIter = (*subprodIter).conditions.begin();
-				 condIter != (*subprodIter).conditions.end(); condIter++) {
-				vector<SString>::iterator searchIter = find(paramNames.begin(), paramNames.end(), 
-															(*condIter).parameter);
-				if (searchIter == paramNames.end()) { //unknown parameter name!
-					//choose random existing parameter
-					(*condIter).parameter = paramNames[randomN(paramNames.size())];
+			if (paramNames.size() > 0) {
+				for (vector<Condition>::iterator condIter = (*subprodIter).conditions.begin();
+					 condIter != (*subprodIter).conditions.end(); condIter++) {
+					vector<SString>::iterator searchIter = find(paramNames.begin(), paramNames.end(), 
+																(*condIter).parameter);
+					if (searchIter == paramNames.end()) { //unknown parameter name!
+						//choose random existing parameter
+						(*condIter).parameter = paramNames[randomN(paramNames.size())];
+					}
 				}
+			} else { //no params, so delete all conditions
+				(*subprodIter).conditions.clear();
 			}
 			
@@ -1109,13 +1140,17 @@
 				SString &actionName = (*actionIter).action->name;
 				if (actionName[0] == 'n') {
-					vector<SString>::iterator searchIter = find(paramNames.begin(), paramNames.end(), 
-																actionName);
-					if (searchIter != paramNames.end()) { //valid name
-						//ensure it is linked to the correct production
-						(*actionIter).action = newLsystem->getParamProduction(actionName);
-					} else {
-						//link to random parameter prodution
-						SString name = paramNames[randomN(paramNames.size())];
-						(*actionIter).action = newLsystem->getParamProduction(name);
+					if (paramNames.size() > 0) {
+						vector<SString>::iterator searchIter = find(paramNames.begin(), paramNames.end(), 
+																	actionName);
+						if (searchIter != paramNames.end()) { //valid name
+							//ensure it is linked to the correct production
+							(*actionIter).action = newLsystem->getParamProduction(actionName);
+						} else {
+							//link to random parameter prodution
+							SString name = paramNames[randomN(paramNames.size())];
+							(*actionIter).action = newLsystem->getParamProduction(name);
+						}
+					} else { //no params, so delete this param production
+						(*subprodIter).actions.erase(actionIter);  //TODO sprawdzić zachowanie iteratora!!!
 					}
 				} else if (actionName[0] == 'P') {
