Index: experiments/frams/deathmatch/data/scripts/deathmatch.expdef
===================================================================
--- experiments/frams/deathmatch/data/scripts/deathmatch.expdef	(revision 231)
+++ experiments/frams/deathmatch/data/scripts/deathmatch.expdef	(revision 233)
@@ -26,47 +26,47 @@
   initPopulations();
   
-  Shapes.set("1p_weaponbox","//0\n"+
-  "p:-0.5, -0.5, -0.5\n"+
-  "p: 0.5, -0.5, -0.5\n"+
-  "p: 0.5, 0.5, -0.5\n"+
-  "p: -0.5, 0.5, -0.5\n"+
-  "p:-0.5, -0.5, 0.5\n"+
-  "p:0.5, -0.5, 0.5\n"+
-  "p:0.5, 0.5, 0.5\n"+
-  "p:-0.5, 0.5, 0.5\n"+
-  "j: 0,1\n"+
-  "j: 1,2\n"+
-  "j: 2,3\n"+
-  "j: 3,0\n"+
-  "j: 4,5\n"+
-  "j: 5,6\n"+
-  "j: 6,7\n"+
-  "j: 7,4\n"+
-  "j: 0,4\n"+
-  "j: 1,5\n"+
-  "j: 2,6\n"+
-  "j: 3,7", 0x0FAA0F);
-  
-  Shapes.set("1p_hpbox","//0\n"+
-  "p:-0.5, -0.5, -0.5\n"+
-  "p: 0.5, -0.5, -0.5\n"+
-  "p: 0.5, 0.5, -0.5\n"+
-  "p: -0.5, 0.5, -0.5\n"+
-  "p:-0.5, -0.5, 0.5\n"+
-  "p:0.5, -0.5, 0.5\n"+
-  "p:0.5, 0.5, 0.5\n"+
-  "p:-0.5, 0.5, 0.5\n"+
-  "j: 0,1\n"+
-  "j: 1,2\n"+
-  "j: 2,3\n"+
-  "j: 3,0\n"+
-  "j: 4,5\n"+
-  "j: 5,6\n"+
-  "j: 6,7\n"+
-  "j: 7,4\n"+
-  "j: 0,4\n"+
-  "j: 1,5\n"+
-  "j: 2,6\n"+
-  "j: 3,7", 0xAA0F0F);
+  Shapes.set("1p_weaponbox","""//0
+p:-0.5, -0.5, -0.5
+p: 0.5, -0.5, -0.5
+p: 0.5, 0.5, -0.5
+p: -0.5, 0.5, -0.5
+p:-0.5, -0.5, 0.5
+p:0.5, -0.5, 0.5
+p:0.5, 0.5, 0.5
+p:-0.5, 0.5, 0.5
+j: 0,1
+j: 1,2
+j: 2,3
+j: 3,0
+j: 4,5
+j: 5,6
+j: 6,7
+j: 7,4
+j: 0,4
+j: 1,5
+j: 2,6
+j: 3,7""", 0x0FAA0F);
+  
+  Shapes.set("1p_hpbox","""//0
+p:-0.5, -0.5, -0.5
+p: 0.5, -0.5, -0.5
+p: 0.5, 0.5, -0.5
+p: -0.5, 0.5, -0.5
+p:-0.5, -0.5, 0.5
+p:0.5, -0.5, 0.5
+p:0.5, 0.5, 0.5
+p:-0.5, 0.5, 0.5
+j: 0,1
+j: 1,2
+j: 2,3
+j: 3,0
+j: 4,5
+j: 5,6
+j: 6,7
+j: 7,4
+j: 0,4
+j: 1,5
+j: 2,6
+j: 3,7""", 0xAA0F0F);
 }
 
@@ -77,37 +77,36 @@
   
   //add Food population (group 0)
-  Population.name = "Food";
-  Population.nnsim = 0;
-  Population.enableperf = 0;
-  Population.death = 1;
-  Population.energy = 1;
-  Population.selfmask = 0x20002;
-  Population.othermask = 0x10002;
+  var p=Populations[0];
+  p.name = "Food";
+  p.nnsim = 0;
+  p.enableperf = 0;
+  p.death = 1;
+  p.energy = 1;
+  p.selfmask = 0x20002;
+  p.othermask = 0x10002;
   
   //add Weapon Upgrade population (group 1)
-  Populations.addGroup("Upgrades");
-  Population.nnsim = 0;
-  Population.enableperf = 0;
-  Population.death = 1;
-  Population.energy = 1;
-  Population.selfmask = 0x20002;
-  Population.othermask = 0x10002;
+  p=Populations.addGroup("Upgrades");
+  p.nnsim = 0;
+  p.enableperf = 0;
+  p.death = 1;
+  p.energy = 1;
+  p.selfmask = 0x20002;
+  p.othermask = 0x10002;
 
   //add Teams populations (group above 2)
   var i = 0;
   teams = ExpParams.teamCount;
-  if (teams == 1) {
-	GenePools.group = 0;
-	teams = GenePool.size;
-  }
+  if (teams == 1)
+	teams = GenePools[0].size;
   for (i = 0; i < teams; i++)
   {
-    Populations.addGroup("Team "+i);
-    Population.nnsim = 1;
-    Population.enableperf = 1;
-    Population.death = 0;
-    Population.energy = 1;
-    Population.selfmask = 0x50001;
-    Population.othermask = 0x60001;
+    p=Populations.addGroup("Team "+i);
+    p.nnsim = 1;
+    p.enableperf = 1;
+    p.death = 0;
+    p.energy = 1;
+    p.selfmask = 0x50001;
+    p.othermask = 0x60001;
   }
   
@@ -127,18 +126,14 @@
 function initCreatures()
 {
-  var i = 0;
-  var j = 0;
-  GenePools.group = 0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	for (j = 0; j < ExpParams.teamSize; j++)
+  for (var i = 0; i < Populations.size - 2; i++)
+  {
+	for (var j = 0; j < ExpParams.teamSize; j++)
 	{
+	  var g; //Genotype object
 	  if (ExpParams.teamCount != 1)
-		GenePools.genotype = Math.random(GenePool.size);
+	    g = GenePools[0].random();
 	  else
-	    GenePools.genotype = i;
-	  Population.createFromGenotype();
-	  Creature.name = "Member " + j;
+	    g = GenePools[0][i];
+	  Populations[i+2].add(g).name = "Member " + j;
 	}
   }
@@ -169,6 +164,5 @@
   
   var s = "#Time interval; ";
-  var i = 0;
-  for (i = 0; i < Populations.size - 2; i++)
+  for (var i = 0; i < Populations.size - 2; i++)
   {
     s += "Team " + i + "; ";
@@ -204,11 +198,9 @@
 function tryCreateHPBox()
 {
-  Populations.group = 0;
-  
-  if (Population.size >= ExpParams.hpBoxTotalCount) return;
+  if (Populations[0].size >= ExpParams.hpBoxTotalCount) return;
   
   if (Math.rnd01 > ExpParams.hpBoxProbability) return;
   
-  var food = Populations.createFromString("//0\nm:Vstyle=hpbox\np:");
+  var food = Populations[0].add("//0\nm:Vstyle=hpbox\np:");
   food.name = "HP Box";
   food.idleen = ExpParams.hpBoxIdleEnergy;
@@ -220,11 +212,9 @@
 function tryCreateUpgradeBox()
 {
-  Populations.group = 1;
-  
-  if (Population.size >= ExpParams.upgradeBoxTotalCount) return;
+  if (Populations[1].size >= ExpParams.upgradeBoxTotalCount) return;
   
   if (Math.rnd01 > ExpParams.upgradeBoxProbability) return;
   
-  var weapon = Populations.createFromString("//0\nm:Vstyle=weaponbox\np:");
+  var weapon = Populations[1].add("//0\nm:Vstyle=weaponbox\np:");
   weapon.name = "Weapon Box";
   weapon.idleen = ExpParams.upgradeBoxIdleEnergy;
@@ -235,5 +225,5 @@
 
 //handle creature placement in the world
-function onBorn()
+function onBorn(cr)
 {
   // place newly born creature
@@ -242,32 +232,24 @@
   while (retry-- && !placed_ok)
   {
-    switch (Populations.group)
+    switch (cr.population.index)
     {
     case 0: //food placement
-      place_centerhead();
+      place_centerhead(cr);
       break;
     case 1: //upgrade placement
-      place_centerhead();
+      place_centerhead(cr);
       break;
     default:
-	  Creature.user1 = Vector.new();
-	  Creature.user1.add(0.0); //attack cooldown (0)
-	  Creature.user1.add(0.0); //bonus damage (1)
-	  Creature.user2 = Vector.new();
-	  Creature.user2.add(0); //kills (0)
-	  Creature.user2.add(0); //assists (1)
-	  Creature.user2.add(0); //total damage dealt (2)
-	  Creature.user2.add(0); //total damage received (3)
-	  Creature.user2.add(0); //HP boxes collected (4)
-	  Creature.user2.add(0); //Upgrade boxes collected (5)
-	  Creature.user3 = Vector.new(); //who dealt damage to this creature
-	  Creature.energ0 = ExpParams.creatureStartingEnergy;
-	  Creature.energy = Creature.energ0;
-      place_inTeamSpot();
+	  cr.user1 = [0.0, 0.0]; //attack cooldown (0), bonus damage (1)
+	  cr.user2 = [0,0,0,0,0,0]; //kills (0), assists (1), total damage dealt (2), total damage received (3), HP boxes collected (4), Upgrade boxes collected (5)
+	  cr.user3 = []; //who dealt damage to this creature
+	  cr.energ0 = ExpParams.creatureStartingEnergy;
+	  cr.energy = cr.energ0;
+      place_inTeamSpot(cr);
       break;
     }
 
-    if (!Populations.creatBBCollisions(0))
-      placed_ok = 1;
+    if (!cr.boundingBoxCollisions(0))
+      {placed_ok=1; break;}
   }
   if (!placed_ok)
@@ -276,9 +258,9 @@
 
 //place creature in random spot and make it head center of the map
-function place_centerhead()
+function place_centerhead(cr)
 {
   var x, y, z;
-  x = (World.wrldsiz - Creature.size_x) * Math.rnd01 - Creature.size_x / 2;
-  y = (World.wrldsiz - Creature.size_y) * Math.rnd01 - Creature.size_y / 2;
+  x = (World.wrldsiz - cr.size_x) * Math.rnd01 - cr.size_x / 2;
+  y = (World.wrldsiz - cr.size_y) * Math.rnd01 - cr.size_y / 2;
   z = WorldMap.getHeight(x, y);
 
@@ -287,6 +269,6 @@
   var alpha_rad = vectorsAngle([1.0, 0.0], [hx, hy]);
 
-  Creature.rotate(0, 0, alpha_rad);
-  Creature.moveAbs(x, y, z - 0.999);
+  cr.rotate(0, 0, alpha_rad);
+  cr.moveAbs(x, y, z - 0.999);
   
   print("Creature placed in [" + x +" " + y + " " + z);
@@ -297,11 +279,11 @@
 //Place creature in correct team spot (valid for Team creatures only)
 //Creatures are placed in circle with random rotation (commented out: heading center of the map) in their respective team groups
-function place_inTeamSpot()
-{
-  var radius = 360.00 * (Populations.group - 1) / teams;
+function place_inTeamSpot(cr)
+{
+  var radius = 360.00 * (cr.population.index - 1) / teams;
 
   var x, y, z;
-  x = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - Creature.size_x / 2 - ExpParams.teamSpawningAreaSize/2;
-  y = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - Creature.size_y / 2 - ExpParams.teamSpawningAreaSize/2;
+  x = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - cr.size_x / 2 - ExpParams.teamSpawningAreaSize/2;
+  y = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - cr.size_y / 2 - ExpParams.teamSpawningAreaSize/2;
   
   //vector of length half the world size minus spawning area size
@@ -324,7 +306,7 @@
   //var alpha_rad = vectorsAngle([1.0, 0.0], [hx, hy]);
   
-  Creature.rotate(0, 0, alpha_rad);
+  cr.rotate(0, 0, alpha_rad);
   //place it mid-air
-  Creature.moveAbs(x, y, z);
+  cr.moveAbs(x, y, z);
 
   return ;
@@ -350,19 +332,14 @@
 {
   var s = "" + Simulator.time + "; ";
-  var i = 0;
-  var j = 0;
   var total = 0.0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	var sum = 0.0;
-	for (j = 0; j < Population.size; j++)
-	{
-	  Populations.creature = j;
-	  sum += Creature.energy;
-	}
+  for (var i = 2; i < Populations.size; i++)
+  {
+    var pop=Populations[i];
+    var sum = 0.0;
+    for (var cr in pop)
+      sum += cr.energy;
     s += "" + sum + "; ";
-	s += "" + Population.size + "; ";
-	total += sum;
+    s += "" + pop.size + "; ";
+    total += sum;
   }
   if (total < 0) total == 0;
@@ -376,49 +353,37 @@
 function clearDeadCreatures()
 {
-  var i = 0;
-  var j = 0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	for (j = 0; j < Population.size; j++)
+  for (var i = 2; i < Populations.size; i++)
+  {
+    var pop=Populations[i];
+    for (var j = 0; j < pop.size; j++)
+      {
+      var cr=pop[j];
+      if (cr.energy <= 0) {pop.kill(cr); j--;}
+      }
+  }
+}
+
+function applySuddenDeathModifier()
+{
+  if (idleSimulationSteps < ExpParams.stagnationInterval) return;
+
+  for (var i = 2; i < Populations.size; i++)
+    for (var cr in Populations[i])
+      cr.energy -= ExpParams.stagnationHealthReduce;
+}
+
+function lowerCooldownCounters()
+{
+  for (var i = 2; i < Populations.size; i++)
+  {
+    var pop=Populations[i];
+	for (var cr in pop)
 	{
-      Populations.creature = j;
-      if (Creature.energy <= 0) Populations.killSelected();
-	}
-  }
-}
-
-function applySuddenDeathModifier()
-{
-  if (idleSimulationSteps < ExpParams.stagnationInterval) return;
-
-  var i = 0;
-  var j = 0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	for (j = 0; j < Population.size; j++)
-	{
-	  Populations.creature = j;
-	  Creature.energy -= ExpParams.stagnationHealthReduce;
-	}
-  }
-}
-function lowerCooldownCounters()
-{
-  var i = 0;
-  var j = 0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	for (j = 0; j < Population.size; j++)
-	{
-	  Populations.creature = j;
-	  if (Creature.user1 != null)
+	  if (cr.user1 != null)
 	  {
-	    if (Creature.user1.get(0) > 0) Creature.user1.set(0, Creature.user1.get(0) - 1);
-	    if (Creature.user1.get(0) < 0) Creature.user1.set(0,0.0);
-	    if (Creature.user1.get(1) > 0) Creature.user1.set(1, Creature.user1.get(1) - ExpParams.upgradeBoxDecay);
-	    if (Creature.user1.get(1) < 0) Creature.user1.set(1,0.0);
+	    if (cr.user1[0] > 0) cr.user1[0]=cr.user1[0] - 1;
+	    if (cr.user1[0] < 0) cr.user1[0]=0.0;
+	    if (cr.user1[1] > 0) cr.user1[1]=cr.user1[1] - ExpParams.upgradeBoxDecay;
+	    if (cr.user1[1] < 0) cr.user1[1]=0.0;
 	  }
 	}
@@ -428,11 +393,7 @@
 function checkGameState()
 {
-  var i = 0;
   var alivePop = 0;
-  for (i = 0; i < Populations.size - 2; i++)
-  {
-    Populations.group = i + 2;
-	if (Population.size > 0) alivePop += 1;
-  }
+  for (var i = 2; i < Populations.size; i++)
+    if (Populations[i].size > 0) alivePop += 1;
   
   if (alivePop == 0 && Simulator.time <= 1)
@@ -444,20 +405,18 @@
   if (alivePop <= 1)
   {
-    for (i = 0; i < Populations.size - 2; i++)
+    for (var i = 2; i < Populations.size; i++)
     {
-      Populations.group = i + 2;
-	  if (Population.size > 0)
+      var pop=Populations[i];
+	  if (pop.size > 0)
 	  {
-	    Simulator.print("Battle is OVER! The winner is: " + Population.name);
+	    Simulator.print("Battle is OVER! The winner is: " + pop.name);
 		
 		//write stats of last living creatures
 		var f=File.appendDirect("creatures"+battleNumber+".txt","Creature statistics");
-		var j = 0;
-		for (j = 0; j < Population.size; j++)
+		for (var cr in pop)
 		{
-		  Populations.creature = j;
 		  //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan");
-		  if (Creature.user2 != null)
-		    f.writeString(Creature.name + "; " + Population.name + "; " + Creature.user2.get(0) + "; " + Creature.user2.get(1) + "; " + Creature.user2.get(2) + "; " + Creature.user2.get(3) + "; " + Creature.user2.get(4) + "; " + Creature.user2.get(5) + "; " + Creature.lifespan + "\n");
+		  if (cr.user2 != null)
+		    f.writeString(cr.name + "; " + pop.name + "; " + cr.user2[0] + "; " + cr.user2[1] + "; " + cr.user2[2] + "; " + cr.user2[3] + "; " + cr.user2[4] + "; " + cr.user2[5] + "; " + cr.lifespan + "\n");
 		}
 
@@ -502,5 +461,5 @@
   }
   
-  if (c1.group == null || c2.group == null)
+  if (c1.population == null || c2.population == null)
   {
     //collision of creature without a group
@@ -510,5 +469,5 @@
   
   //first condition should never occur, but who knows?
-  if (c1.group.index < 2 || c2.group.index < 2)
+  if (c1.population.index < 2 || c2.population.index < 2)
   {
     //collision with HP Box and Upgrades are handled separately
@@ -524,6 +483,5 @@
   var dice2 = 0;
   var changed = 0;
-  var i = 0;
-  for (i = 0; i < ExpParams.diceCount; i++)
+  for (var i = 0; i < ExpParams.diceCount; i++)
   {
     dice1 = dice1 + Math.random(ExpParams.diceSides) + 1;
@@ -534,5 +492,5 @@
   energy1 += ExpParams.upgradeMultiplier * c1.user1.get(1);
   energy2 += ExpParams.upgradeMultiplier * c2.user1.get(1);
-  if (c1.group == c2.group)
+  if (c1.population == c2.population)
   {
     energy1 = ExpParams.friendlyFireDamageMultiplier * energy1;
@@ -547,5 +505,5 @@
   if (c2.user2 == null) stop("3");
   
-  if (c2.user1.get(0) <= 0 && energy2 > 0)
+  if (c2.user1[0] <= 0 && energy2 > 0)
   {
     changed = 1;
@@ -553,16 +511,14 @@
     c1.energy = c1.energy - energy2;
 	if (c1.energy < 0) c1.energy = 0;
-    print(c2.name + " [" + c2.group.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpParams.upgradeMultiplier * c2.user1.get(1)) +" bonus] damage to " + c1.name + " [" + c1.group.name + "]");
+    print(c2.name + " [" + c2.population.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpParams.upgradeMultiplier * c2.user1[1]) +" bonus] damage to " + c1.name + " [" + c1.population.name + "]");
 	c2.user1.set(0, ExpParams.attackCooldown);
-	c2.user2.set(2, c2.user2.get(2) + energy1);
-	c1.user2.set(3, c1.user2.get(3) + energy1);
-	var vect = Vector.new();
-	vect.add(c2.uid);
-	vect.add(c2.name);
+	c2.user2.set(2, c2.user2[2] + energy1);
+	c1.user2.set(3, c1.user2[3] + energy1);
+	var vect = [c2.uid,c2.name];
 	var arrindex = arrayContains(c1.user3, 0, c2.uid);
 	if (arrindex != -1)
 	{
-	  vect.add(energy2 + c1.user3.get(arrindex).get(2));
-	  c1.user3.set(arrindex, vect);
+	  vect.add(energy2 + c1.user3[arrindex][2]);
+	  c1.user3[arrindex]=vect;
 	}
 	else
@@ -572,16 +528,14 @@
 	  c1.user3.add(vect);
 	  if (c1.energy > 0)
-	  {
-        c2.user2.set(1, c2.user2.get(1) + 1); //increase assists statistic
-	  }
+            c2.user2[1] = c2.user2[1] + 1; //increase assists statistic
 	}
 	if (c1.energy <= 0)
 	{
-	  c2.user2.set(0, c2.user2.get(0) + 1); //increase kills statistic
+	  c2.user2[0] = c2.user2[0] + 1; //increase kills statistic
 	  kill_c1 = 1;
 	}
   }
   
-  if (c1.user1.get(0) <= 0 && energy1 > 0)
+  if (c1.user1[0] <= 0 && energy1 > 0)
   {
     changed = 1;
@@ -589,8 +543,8 @@
     c2.energy = c2.energy - energy1;
 	if (c2.energy < 0) c2.energy = 0;
-    print(c1.name + " [" + c1.group.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpParams.upgradeMultiplier * c1.user1.get(1)) +" bonus] damage to " + c2.name + " [" + c2.group.name + "]");
-    c1.user1.set(0, ExpParams.attackCooldown);
-	c1.user2.set(2, c1.user2.get(2) + energy1);
-	c2.user2.set(3, c2.user2.get(3) + energy1);
+    print(c1.name + " [" + c1.population.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpParams.upgradeMultiplier * c1.user1[1]) +" bonus] damage to " + c2.name + " [" + c2.population.name + "]");
+    c1.user1[0] = ExpParams.attackCooldown;
+	c1.user2[2] = c1.user2[2] + energy1;
+	c2.user2[3] = c2.user2[3] + energy1;
 	var vect = Vector.new();
 	vect.add(c1.uid);
@@ -599,6 +553,6 @@
 	if (arrindex != -1)
 	{
-	  vect.add(energy1 + c2.user3.get(arrindex).get(2));
-	  c2.user3.set(arrindex, vect);
+	  vect.add(energy1 + c2.user3[arrindex][2]);
+	  c2.user3[arrindex] = vect;
 	}
 	else
@@ -609,10 +563,10 @@
 	  if (c2.energy > 0)
 	  {
-        c1.user2.set(1, c1.user2.get(1) + 1); //increase assists statistic
+        c1.user2[1] = c1.user2[1] + 1; //increase assists statistic
 	  }
 	}
 	if (c2.energy <= 0)
 	{
-	  c1.user2.set(0, c1.user2.get(0) + 1); //increase kills statistic
+	  c1.user2[0] = c1.user2[0] + 1; //increase kills statistic
 	  kill_c2 = 1;
 	}
@@ -626,17 +580,7 @@
   //resolve kills
   if (kill_c1 == 1)
-  {
-    Populations.group = c1.group.index;
-    Populations.creature = c1.group.findUID(c1.uid);
-	if (Populations.creature == -1) stop("4");
-    Populations.killSelected();
-  }
+    c1.population.kill(c1);
   if (kill_c2 == 1)
-  {
-    Populations.group = c2.group.index;
-    Populations.creature = c2.group.findUID(c2.uid);
-	if (Populations.creature == -1) stop("4");
-    Populations.killSelected();
-  }
+    c2.population.kill(c2);
 }
 
@@ -647,13 +591,11 @@
 
   //collect HP Box (by eating it :D)
-  print(Collision.Creature2.name + " [" + Collision.Creature2.group.name + "] picked a HP box");
-  Collision.Creature2.user2.set(4, Collision.Creature2.user2.get(4) + 1);
-  Collision.Creature1.energy_m = Collision.Creature1.energy_m + Collision.Creature1.energy;
-  Collision.Creature2.energy_p = Collision.Creature2.energy_p + Collision.Creature1.energy;
+  print(Collision.Creature2.name + " [" + Collision.Creature2.population.name + "] picked a HP box");
+  Collision.Creature2.user2[4] = Collision.Creature2.user2[4] + 1;
+  Collision.Creature1.energy_m += Collision.Creature1.energy;
+  Collision.Creature2.energy_p += Collision.Creature1.energy;
   
   //kill HP Box
-  Populations.group = Collision.Creature1.group.index;
-  Populations.creature = Collision.Creature1.group.findUID(Collision.Creature1.uid);
-  Populations.killSelected();
+  Collision.Creature1.population.kill(Collision.Creature1);
   
   writeTeamStatistics();
@@ -666,13 +608,11 @@
 
   //collect Upgrade Box (by eating it :D)
-  print(Collision.Creature2.name + " [" + Collision.Creature2.group.name + "] picked an upgrade box");
-  Collision.Creature2.user2.set(5, Collision.Creature2.user2.get(5) + 1);
-  Collision.Creature1.energy_m = Collision.Creature1.energy_m + Collision.Creature1.energy;
-  Collision.Creature2.user1.set(1, Collision.Creature2.user1.get(1) + Collision.Creature1.energy);
+  print(Collision.Creature2.name + " [" + Collision.Creature2.population.name + "] picked an upgrade box");
+  Collision.Creature2.user2[5] = Collision.Creature2.user2[5] + 1;
+  Collision.Creature1.energy_m += Collision.Creature1.energy;
+  Collision.Creature2.user1[1] = Collision.Creature2.user1[1] + Collision.Creature1.energy;
   
   //kill Upgrade Box
-  Populations.group = Collision.Creature1.group.index;
-  Populations.creature = Collision.Creature1.group.findUID(Collision.Creature1.uid);
-  Populations.killSelected();
+  Collision.Creature1.population.kill(Collision.Creature1);
   
   writeTeamStatistics();
@@ -681,20 +621,17 @@
 //function executed on Creature death
 //TODO: implement some statistics for dieing creature
-function onDied()
+function onDied(cr)
 {
   //ignore death of hp boxes and upgrades
-  if (Populations.group < 2)
+  if (cr.population.index < 2)
    return ;
 
-  print(Creature.name + " was killed");
-  var i = 0;
-  for (i = 0; i < Creature.user3.size; i++)
-  {
-    print(Creature.user3.get(i).get(1) + " dealt " + Creature.user3.get(i).get(2) + " damage");
-  }
+  print(cr.name + " was killed");
+  for (var dam in cr.user3)
+    print(dam[1] + " dealt " + dam[2] + " damage");
   
   var f=File.appendDirect("creatures"+battleNumber+".txt","Creature statistics");
   //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan");
-  f.writeString(Creature.name + "; " + Population.name + "; " + Creature.user2.get(0) + "; " + Creature.user2.get(1) + "; " + Creature.user2.get(2) + "; " + Creature.user2.get(3) + "; " + Creature.user2.get(4) + "; " + Creature.user2.get(5) + "; " + Creature.lifespan + "\n");
+  f.writeString(cr.name + "; " + cr.population.name + "; " + cr.user2[0] + "; " + cr.user2[1] + "; " + cr.user2[2] + "; " + cr.user2[3] + "; " + cr.user2[4] + "; " + cr.user2[5] + "; " + cr.lifespan + "\n");
   f.close();
   
