Index: branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/GEEvaluator.cs
===================================================================
--- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/GEEvaluator.cs	(revision 10022)
+++ branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/GEEvaluator.cs	(revision 10029)
@@ -40,8 +40,4 @@
     ISingleObjectiveEvaluator, ISymbolicExpressionTreeGrammarBasedOperator {
 
-    // TODO: replace these horrible global variables ...
-    private static int genotypeIndex    = 0;
-    private static int currSubtreeCount = 1;
-    
   	#region Parameter Properties
     public ILookupParameter<DoubleValue> QualityParameter {
@@ -96,5 +92,6 @@
     
     /// <summary>
-    /// Genotype-to-Phenotype mapper (depth-first approach).
+    /// Maps an integer vector to a symbolic expression tree, using a 
+    /// genotype-to-phenotype mapper.
     /// </summary>
     /// <returns>solution tree</returns>
@@ -109,9 +106,10 @@
       tree.Root = rootNode;
       
-      genotypeIndex    = 0;
-      currSubtreeCount = 1;
+      int genotypeIndex    = 0;
+      int currSubtreeCount = 1;
       
       MapGenoToPhenoDepthFirstRec(startNode, integerVectorGenome,
-                                  grammar, integerVectorGenome.Length);
+                                  grammar, integerVectorGenome.Length,
+                                  ref genotypeIndex, ref currSubtreeCount);
      
       SymbolicExpressionTreeParameter.ActualValue = tree;
@@ -120,8 +118,25 @@
     
     
+    /// <summary>
+    /// Genotype-to-Phenotype mapper (recursive depth-first approach).
+    /// Appends maximum allowed children (non-terminal symbols) to
+    /// <paramref name="currentNode"/>, as long as <paramref name="currSubtreeCount"/>
+    /// doesn't exceed <paramref name="maxSubtreeCount"/>.
+    /// If at most <paramref name="maxSubtreeCount"/> subtrees were created,
+    /// each non-full node is filled with randomly chosen nodes
+    /// (non-terminal and terminal), and each non-terminal node is again filled with a terminal node.
+    /// </summary>
+    /// <param name="currentNode">current parent node</param>
+    /// <param name="integerVectorGenome">integer vector used for mapping</param>
+    /// <param name="grammar">grammar definition to determine the allowed child symbols for currentNode </param>
+    /// <param name="maxSubtreeCount">maximum allowed subtrees (= number of used genomes)</param>
+    /// <param name="genotypeIndex">current index in integer vector</param>
+    /// <param name="currSubtreeCount">number of already determined subtrees (filled or still incomplete)</param>
     private void MapGenoToPhenoDepthFirstRec(ISymbolicExpressionTreeNode currentNode,
                                              IntegerVector integerVectorGenome,
                                              ISymbolicExpressionGrammar grammar,
-                                             int maxSubtreeCount) {
+                                             int maxSubtreeCount,
+                                             ref int genotypeIndex,
+                                             ref int currSubtreeCount) {
     	if (currSubtreeCount < maxSubtreeCount) {
     	
@@ -138,5 +153,6 @@
 	    	  while (newNode.Symbol.MaximumArity > newNode.SubtreeCount) {
 	    		  MapGenoToPhenoDepthFirstRec(newNode, integerVectorGenome, 
-	    	                                grammar, maxSubtreeCount);
+	    	                                grammar, maxSubtreeCount,
+	    	                                ref genotypeIndex, ref currSubtreeCount);
 	    	  }
         }
@@ -156,5 +172,5 @@
     
     /// <summary>
-    /// Randomly returns a terminal node for the given parentNode.
+    /// Randomly returns a terminal node for the given <paramref name="parentNode"/>.
     /// (A terminal has got a minimum and maximum arity of 0.)
     /// </summary>
@@ -174,5 +190,5 @@
     
     /// <summary>
-    /// Utility method, which returns the number of elements of the parameter symbolList.
+    /// Utility method, which returns the number of elements of <paramref name="symbolList"/>.
     /// </summary>
     /// <param name="symbolList">enumerable symbol list to count the elements for</param>
@@ -190,5 +206,5 @@
     
     /// <summary>
-    /// Returns a randomly chosen child node for the given parentNode.
+    /// Returns a randomly chosen child node for the given <paramref name="parentNode"/>.
     /// </summary>
     /// <param name="parentNode">parent node to find a child node randomly for</param>
@@ -204,5 +220,5 @@
       var symbolList    = grammar.GetAllowedChildSymbols(parentNode.Symbol);
       int prodRuleCount = GetNumberOfAllowedChildSymbols(symbolList);
-      int prodRuleIndex = integerVectorGenome[genotypeIndex] % prodRuleCount;
+      int prodRuleIndex = integerVectorGenome[genotypeIndex % integerVectorGenome.Length] % prodRuleCount;
       int currentIndex  = 0;
       
