Index: branches/GP-Refactoring-713/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs	(revision 2211)
@@ -382,4 +382,5 @@
         cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>();
       }
+      cachedValuesInvalidated = false;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs	(revision 2211)
@@ -33,6 +33,6 @@
     void RemoveAllowedSubFunction(IFunction f, int index);
     bool IsAllowedSubFunction(IFunction f, int index);
-    int MinArity { get; }
-    int MaxArity { get; }
+    int MinSubTrees { get; }
+    int MaxSubTrees { get; }
     int MinTreeHeight { get; }
     int MinTreeSize { get; }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs	(revision 2211)
@@ -46,4 +46,5 @@
     private const string VOTES = "Votes";
     private const string ACCURACY = "Accuracy";
+    private const string TREEEVALUATOR = "TreeEvaluator";
 
     private const double EPSILON = 1E-6;
@@ -65,4 +66,5 @@
       AddVariableInfo(new VariableInfo(BESTMODELLSCOPE, "The variable containing the scope of the model (incl. meta data)", typeof(IScope), VariableKind.In));
       AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(IGeneticProgrammingModel), VariableKind.In));
+      AddVariableInfo(new VariableInfo(TREEEVALUATOR, "The evaluator to apply to the function tree", typeof(ITreeEvaluator), VariableKind.In));
       AddVariableInfo(new VariableInfo(VOTES, "Array with the votes for each instance", typeof(IntMatrixData), VariableKind.New));
       AddVariableInfo(new VariableInfo(ACCURACY, "Accuracy of the one-vs-one multi-cass classifier", typeof(DoubleData), VariableKind.New));
@@ -85,5 +87,5 @@
         IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>(BESTMODELL, bestScope, true);
 
-        BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
+        ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>(TREEEVALUATOR, bestScope, true);
         evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0, gpModel.FunctionTree);
         for(int i = 0; i < (samplesEnd - samplesStart); i++) {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Addition.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Addition.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Addition.cs	(revision 2211)
@@ -42,6 +42,6 @@
       : base() {
       // 2 - 3 seems like an reasonable defaut (used for +,-,*,/) (discussion with swinkler and maffenze)
-      MinArity = 2;
-      MaxArity = 3;
+      MinSubTrees = 2;
+      MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/And.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/And.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/And.cs	(revision 2211)
@@ -38,5 +38,5 @@
     public And()
       : base() {
-      MinArity = 2; MaxArity = 3;
+      MinSubTrees = 2; MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Average.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Average.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Average.cs	(revision 2211)
@@ -36,5 +36,5 @@
     public Average()
       : base() {
-      MinArity = 2; MaxArity = 3;
+      MinSubTrees = 2; MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/BakedTreeEvaluator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/BakedTreeEvaluator.cs	(revision 2210)
+++ 	(revision )
@@ -1,191 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Core;
-using System.Xml;
-using System.Diagnostics;
-using HeuristicLab.DataAnalysis;
-
-namespace HeuristicLab.GP.StructureIdentification {
-  /// <summary>
-  /// Evaluates FunctionTrees recursively by interpretation of the function symbols in each node.
-  /// Not thread-safe!
-  /// </summary>
-  public class BakedTreeEvaluator : TreeEvaluatorBase {
-
-
-    protected override double EvaluateBakedCode() {
-      Instr currInstr = codeArr[PC++];
-      switch (currInstr.symbol) {
-        case EvaluatorSymbolTable.VARIABLE: {
-            int row = sampleIndex + currInstr.i_arg1;
-            if (row < 0 || row >= dataset.Rows) return double.NaN;
-            else return currInstr.d_arg0 * dataset.GetValue(row, currInstr.i_arg0);
-          }
-        case EvaluatorSymbolTable.CONSTANT: {
-            return currInstr.d_arg0;
-          }
-        case EvaluatorSymbolTable.DIFFERENTIAL: {
-            int row = sampleIndex + currInstr.i_arg1;
-            if (row < 0 || row >= dataset.Rows) return double.NaN;
-            else if (row < 1) return 0.0;
-            else {
-              double prevValue = dataset.GetValue(row - 1, currInstr.i_arg0);
-              if (double.IsNaN(prevValue) || double.IsInfinity(prevValue)) return 0.0;
-              else return currInstr.d_arg0 * (dataset.GetValue(row, currInstr.i_arg0) - prevValue);
-            }
-          }
-        case EvaluatorSymbolTable.MULTIPLICATION: {
-            double result = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              result *= EvaluateBakedCode();
-            }
-            return result;
-          }
-        case EvaluatorSymbolTable.ADDITION: {
-            double sum = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              sum += EvaluateBakedCode();
-            }
-            return sum;
-          }
-        case EvaluatorSymbolTable.SUBTRACTION: {
-            double result = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              result -= EvaluateBakedCode();
-            }
-            return result;
-          }
-        case EvaluatorSymbolTable.DIVISION: {
-            double result;
-            result = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              result /= EvaluateBakedCode();
-            }
-            if (double.IsInfinity(result)) return 0.0;
-            else return result;
-          }
-        case EvaluatorSymbolTable.AVERAGE: {
-            double sum = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              sum += EvaluateBakedCode();
-            }
-            return sum / currInstr.arity;
-          }
-        case EvaluatorSymbolTable.COSINUS: {
-            return Math.Cos(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.SINUS: {
-            return Math.Sin(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.EXP: {
-            return Math.Exp(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.LOG: {
-            return Math.Log(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.POWER: {
-            double x = EvaluateBakedCode();
-            double p = EvaluateBakedCode();
-            return Math.Pow(x, p);
-          }
-        case EvaluatorSymbolTable.SIGNUM: {
-            double value = EvaluateBakedCode();
-            if (double.IsNaN(value)) return double.NaN;
-            else return Math.Sign(value);
-          }
-        case EvaluatorSymbolTable.SQRT: {
-            return Math.Sqrt(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.TANGENS: {
-            return Math.Tan(EvaluateBakedCode());
-          }
-        case EvaluatorSymbolTable.AND: { // only defined for inputs 1 and 0
-            double result = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              if (result == 0.0) SkipBakedCode();
-              else {
-                result = EvaluateBakedCode();
-              }
-              Debug.Assert(result == 0.0 || result == 1.0);
-            }
-            return result;
-          }
-        case EvaluatorSymbolTable.EQU: {
-            double x = EvaluateBakedCode();
-            double y = EvaluateBakedCode();
-            if (Math.Abs(x - y) < EPSILON) return 1.0; else return 0.0;
-          }
-        case EvaluatorSymbolTable.GT: {
-            double x = EvaluateBakedCode();
-            double y = EvaluateBakedCode();
-            if (x > y) return 1.0;
-            else return 0.0;
-          }
-        case EvaluatorSymbolTable.IFTE: { // only defined for condition 0 or 1
-            double condition = EvaluateBakedCode();
-            Debug.Assert(condition == 0.0 || condition == 1.0);
-            double result;
-            if (condition == 0.0) {
-              result = EvaluateBakedCode(); SkipBakedCode();
-            } else {
-              SkipBakedCode(); result = EvaluateBakedCode();
-            }
-            return result;
-          }
-        case EvaluatorSymbolTable.LT: {
-            double x = EvaluateBakedCode();
-            double y = EvaluateBakedCode();
-            if (x < y) return 1.0;
-            else return 0.0;
-          }
-        case EvaluatorSymbolTable.NOT: { // only defined for inputs 0 or 1
-            double result = EvaluateBakedCode();
-            Debug.Assert(result == 0.0 || result == 1.0);
-            return Math.Abs(result - 1.0);
-          }
-        case EvaluatorSymbolTable.OR: { // only defined for inputs 0 or 1
-            double result = EvaluateBakedCode();
-            for (int i = 1; i < currInstr.arity; i++) {
-              if (result > 0.0) SkipBakedCode();
-              else {
-                result = EvaluateBakedCode();
-                Debug.Assert(result == 0.0 || result == 1.0);
-              }
-            }
-            return result;
-          }
-        case EvaluatorSymbolTable.XOR: { // only defined for inputs 0 or 1
-            double x = EvaluateBakedCode();
-            double y = EvaluateBakedCode();
-            return Math.Abs(x - y);
-          }
-        default: {
-            throw new NotImplementedException();
-          }
-      }
-    }
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs	(revision 2211)
@@ -29,13 +29,20 @@
 namespace HeuristicLab.GP.StructureIdentification {
   public class ConstantFunctionTree : FunctionTreeBase {
+    private static readonly IList<IFunctionTree> subTrees = new List<IFunctionTree>().AsReadOnly();
     public double Value { get; set; }
 
-    public ConstantFunctionTree(Constant constant)
-      : base(constant) {
+    public ConstantFunctionTree(Constant constant) {
+      Function = constant;
     }
 
-    protected ConstantFunctionTree(ConstantFunctionTree original)
-      : base(original) {
+    protected ConstantFunctionTree(ConstantFunctionTree original) {
+      Function = original.Function;
       Value = original.Value;
+    }
+
+    public override IList<IFunctionTree> SubTrees {
+      get {
+        return subTrees;
+      }
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs	(revision 2211)
@@ -238,5 +238,5 @@
 
     private void SetAllowedSubOperators(IFunction f, List<IFunction> gs) {
-      for (int i = 0; i < f.MaxArity; i++) {
+      for (int i = 0; i < f.MaxSubTrees; i++) {
         SetAllowedSubOperators(f, i, gs);
       }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs	(revision 2211)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs	(revision 2211)
@@ -0,0 +1,191 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using System.Xml;
+using System.Diagnostics;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.GP.StructureIdentification {
+  /// <summary>
+  /// Evaluates FunctionTrees recursively by interpretation of the function symbols in each node.
+  /// Not thread-safe!
+  /// </summary>
+  public class HL3TreeEvaluator : TreeEvaluatorBase {
+
+
+    protected override double EvaluateBakedCode() {
+      Instr currInstr = codeArr[PC++];
+      switch (currInstr.symbol) {
+        case EvaluatorSymbolTable.VARIABLE: {
+            int row = sampleIndex + currInstr.i_arg1;
+            if (row < 0 || row >= dataset.Rows) return double.NaN;
+            else return currInstr.d_arg0 * dataset.GetValue(row, currInstr.i_arg0);
+          }
+        case EvaluatorSymbolTable.CONSTANT: {
+            return currInstr.d_arg0;
+          }
+        case EvaluatorSymbolTable.DIFFERENTIAL: {
+            int row = sampleIndex + currInstr.i_arg1;
+            if (row < 0 || row >= dataset.Rows) return double.NaN;
+            else if (row < 1) return 0.0;
+            else {
+              double prevValue = dataset.GetValue(row - 1, currInstr.i_arg0);
+              if (double.IsNaN(prevValue) || double.IsInfinity(prevValue)) return 0.0;
+              else return currInstr.d_arg0 * (dataset.GetValue(row, currInstr.i_arg0) - prevValue);
+            }
+          }
+        case EvaluatorSymbolTable.MULTIPLICATION: {
+            double result = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              result *= EvaluateBakedCode();
+            }
+            return result;
+          }
+        case EvaluatorSymbolTable.ADDITION: {
+            double sum = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              sum += EvaluateBakedCode();
+            }
+            return sum;
+          }
+        case EvaluatorSymbolTable.SUBTRACTION: {
+            double result = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              result -= EvaluateBakedCode();
+            }
+            return result;
+          }
+        case EvaluatorSymbolTable.DIVISION: {
+            double result;
+            result = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              result /= EvaluateBakedCode();
+            }
+            if (double.IsInfinity(result)) return 0.0;
+            else return result;
+          }
+        case EvaluatorSymbolTable.AVERAGE: {
+            double sum = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              sum += EvaluateBakedCode();
+            }
+            return sum / currInstr.arity;
+          }
+        case EvaluatorSymbolTable.COSINUS: {
+            return Math.Cos(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.SINUS: {
+            return Math.Sin(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.EXP: {
+            return Math.Exp(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.LOG: {
+            return Math.Log(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.POWER: {
+            double x = EvaluateBakedCode();
+            double p = EvaluateBakedCode();
+            return Math.Pow(x, p);
+          }
+        case EvaluatorSymbolTable.SIGNUM: {
+            double value = EvaluateBakedCode();
+            if (double.IsNaN(value)) return double.NaN;
+            else return Math.Sign(value);
+          }
+        case EvaluatorSymbolTable.SQRT: {
+            return Math.Sqrt(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.TANGENS: {
+            return Math.Tan(EvaluateBakedCode());
+          }
+        case EvaluatorSymbolTable.AND: { // only defined for inputs 1 and 0
+            double result = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              if (result == 0.0) SkipBakedCode();
+              else {
+                result = EvaluateBakedCode();
+              }
+              Debug.Assert(result == 0.0 || result == 1.0);
+            }
+            return result;
+          }
+        case EvaluatorSymbolTable.EQU: {
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            if (Math.Abs(x - y) < EPSILON) return 1.0; else return 0.0;
+          }
+        case EvaluatorSymbolTable.GT: {
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            if (x > y) return 1.0;
+            else return 0.0;
+          }
+        case EvaluatorSymbolTable.IFTE: { // only defined for condition 0 or 1
+            double condition = EvaluateBakedCode();
+            Debug.Assert(condition == 0.0 || condition == 1.0);
+            double result;
+            if (condition == 0.0) {
+              result = EvaluateBakedCode(); SkipBakedCode();
+            } else {
+              SkipBakedCode(); result = EvaluateBakedCode();
+            }
+            return result;
+          }
+        case EvaluatorSymbolTable.LT: {
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            if (x < y) return 1.0;
+            else return 0.0;
+          }
+        case EvaluatorSymbolTable.NOT: { // only defined for inputs 0 or 1
+            double result = EvaluateBakedCode();
+            Debug.Assert(result == 0.0 || result == 1.0);
+            return Math.Abs(result - 1.0);
+          }
+        case EvaluatorSymbolTable.OR: { // only defined for inputs 0 or 1
+            double result = EvaluateBakedCode();
+            for (int i = 1; i < currInstr.arity; i++) {
+              if (result > 0.0) SkipBakedCode();
+              else {
+                result = EvaluateBakedCode();
+                Debug.Assert(result == 0.0 || result == 1.0);
+              }
+            }
+            return result;
+          }
+        case EvaluatorSymbolTable.XOR: { // only defined for inputs 0 or 1
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            return Math.Abs(x - y);
+          }
+        default: {
+            throw new NotImplementedException();
+          }
+      }
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2211)
@@ -85,9 +85,9 @@
     <Compile Include="And.cs" />
     <Compile Include="Average.cs" />
-    <Compile Include="BakedTreeEvaluator.cs" />
     <Compile Include="Constant.cs" />
     <Compile Include="AlgorithmBase.cs" />
     <Compile Include="ConstantFunctionTree.cs" />
     <Compile Include="Evaluators\SimpleGPEvaluatorBase.cs" />
+    <Compile Include="HL3TreeEvaluator.cs" />
     <Compile Include="VariableFunctionTree.cs" />
     <Compile Include="TreeEvaluatorBase.cs" />
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/IfThenElse.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/IfThenElse.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/IfThenElse.cs	(revision 2211)
@@ -38,5 +38,5 @@
     public IfThenElse()
       : base() {
-      MinArity = 3; MaxArity = 3;
+      MinSubTrees = 3; MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Multiplication.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Multiplication.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Multiplication.cs	(revision 2211)
@@ -43,5 +43,5 @@
       : base() {
       // 2 - 3 seems like an reasonable defaut (used for +,-,*,/) (discussion with swinkler and maffenze)
-      MinArity = 2; MaxArity = 3;
+      MinSubTrees = 2; MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Or.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Or.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Or.cs	(revision 2211)
@@ -37,5 +37,5 @@
     public Or()
       : base() {
-      MinArity = 2; MaxArity = 3;
+      MinSubTrees = 2; MaxSubTrees = 3;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs	(revision 2211)
@@ -29,17 +29,24 @@
 namespace HeuristicLab.GP.StructureIdentification {
   public class VariableFunctionTree : FunctionTreeBase {
+    private static readonly IList<IFunctionTree> subTrees = new List<IFunctionTree>().AsReadOnly();
     public double Weight { get; set; }
     public string VariableName { get; set; }
     public int SampleOffset { get; set; }
 
-    public VariableFunctionTree(Variable variable)
-      : base(variable) {
+    public VariableFunctionTree(Variable variable) {
+      Function = variable;
     }
 
-    protected VariableFunctionTree(VariableFunctionTree original)
-      : base(original) {
+    protected VariableFunctionTree(VariableFunctionTree original) {
+      Function = original.Function;
       Weight = original.Weight;
       VariableName = original.VariableName;
       SampleOffset = original.SampleOffset;
+    }
+
+    public override IList<IFunctionTree> SubTrees {
+      get {
+        return subTrees;
+      }
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BakedFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BakedFunctionTree.cs	(revision 2210)
+++ 	(revision )
@@ -1,368 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using System.Xml;
-using System.Globalization;
-
-namespace HeuristicLab.GP {
-
-  public class LightWeightFunction {
-    public byte arity = 0;
-    public IFunction functionType;
-    public List<IVariable> localData = new List<IVariable>();
-
-    public LightWeightFunction Clone() {
-      LightWeightFunction clone = new LightWeightFunction();
-      clone.arity = arity;
-      clone.functionType = functionType;
-      clone.localData = localData.Select(v=>(IVariable)v.Clone()).ToList();
-      return clone;
-    }
-  }
-
-  public class BakedFunctionTree : ItemBase, IFunctionTree {
-    private List<LightWeightFunction> linearRepresentation;
-    public List<LightWeightFunction> LinearRepresentation {
-      get {
-        FlattenVariables();
-        FlattenTrees();
-        return linearRepresentation;
-      }
-    }
-    private bool treesExpanded = false;
-    private List<IFunctionTree> subTrees;
-    private bool variablesExpanded = false;
-    private List<IVariable> variables = new List<IVariable>();
-
-    public IOperator Initializer {
-      get { return Function.Initializer; }
-    }
-
-    public IOperator Manipulator {
-      get { return Function.Manipulator; }
-    }
-
-    public BakedFunctionTree() {
-      linearRepresentation = new List<LightWeightFunction>();
-    }
-
-    public BakedFunctionTree(IFunction function)
-      : this() {
-      LightWeightFunction fun = new LightWeightFunction();
-      fun.functionType = function;
-      linearRepresentation.Add(fun);
-      treesExpanded = true;
-      subTrees = new List<IFunctionTree>();
-      variables = new List<IVariable>();
-      variablesExpanded = true;
-    }
-
-    //internal BakedFunctionTree(IFunctionTree tree)
-    //  : this() {
-    //  LightWeightFunction fun = new LightWeightFunction();
-    //  fun.functionType = tree.Function;
-    //  linearRepresentation.Add(fun);
-    //  foreach (IVariable variable in tree.LocalVariables) {
-    //    IObjectData value = (IObjectData)variable.Value;
-    //    fun.localData.Add(value.Data);
-    //  }
-    //  foreach (IFunctionTree subTree in tree.SubTrees) {
-    //    AddSubTree(new BakedFunctionTree(subTree));
-    //  }
-    //}
-
-    private int BranchLength(int branchRoot) {
-      int arity = linearRepresentation[branchRoot].arity;
-      int length = 1;
-      for (int i = 0; i < arity; i++) {
-        length += BranchLength(branchRoot + length);
-      }
-      return length;
-    }
-
-    private void FlattenTrees() {
-      if (treesExpanded) {
-        linearRepresentation[0].arity = (byte)subTrees.Count;
-        foreach (BakedFunctionTree subTree in subTrees) {
-          subTree.FlattenVariables();
-          subTree.FlattenTrees();
-          linearRepresentation.AddRange(subTree.linearRepresentation);
-        }
-        treesExpanded = false;
-        subTrees = null;
-      }
-    }
-
-    private void FlattenVariables() {
-      if (variablesExpanded) {
-        linearRepresentation[0].localData.Clear();
-        foreach (IVariable variable in variables) {
-          //object objData = variable.Value;
-          //while (objData is IObjectData) objData = ((IObjectData)objData).Data;
-          //linearRepresentation[0].localData[variable.Name] = objData;
-          linearRepresentation[0].localData.Add(variable);
-        }
-        variablesExpanded = false;
-        variables = null;
-      }
-    }
-
-    public int Size {
-      get {
-        if (treesExpanded) {
-          int size = 1;
-          foreach (BakedFunctionTree tree in subTrees) {
-            size += tree.Size;
-          }
-          return size;
-        } else
-          return linearRepresentation.Count;
-      }
-    }
-
-    public int Height {
-      get {
-        if (treesExpanded) {
-          int height = 0;
-          foreach (IFunctionTree subTree in subTrees) {
-            int curHeight = subTree.Height;
-            if (curHeight > height) height = curHeight;
-          }
-          return height + 1;
-        } else {
-          int nextBranchStart;
-          return BranchHeight(0, out nextBranchStart);
-        }
-      }
-    }
-
-    private int BranchHeight(int branchStart, out int nextBranchStart) {
-      LightWeightFunction f = linearRepresentation[branchStart];
-      int height = 0;
-      branchStart++;
-      for (int i = 0; i < f.arity; i++) {
-        int curHeight = BranchHeight(branchStart, out nextBranchStart);
-        if (curHeight > height) height = curHeight;
-        branchStart = nextBranchStart;
-      }
-      nextBranchStart = branchStart;
-      return height + 1;
-    }
-
-    public IList<IFunctionTree> SubTrees {
-      get {
-        if (!treesExpanded) {
-          subTrees = new List<IFunctionTree>();
-          int arity = linearRepresentation[0].arity;
-          int branchIndex = 1;
-          for (int i = 0; i < arity; i++) {
-            BakedFunctionTree subTree = new BakedFunctionTree();
-            int length = BranchLength(branchIndex);
-            for (int j = branchIndex; j < branchIndex + length; j++) {
-              subTree.linearRepresentation.Add(linearRepresentation[j]);
-            }
-            branchIndex += length;
-            subTrees.Add(subTree);
-          }
-          treesExpanded = true;
-          linearRepresentation.RemoveRange(1, linearRepresentation.Count - 1);
-          linearRepresentation[0].arity = 0;
-        }
-        return subTrees;
-      }
-    }
-
-    public ICollection<IVariable> LocalVariables {
-      get {
-        if (!variablesExpanded) {
-          variables = new List<IVariable>();
-          IFunction function = Function;          
-          //int localVariableIndex = 0;
-          foreach (IVariable v in linearRepresentation[0].localData) {
-            //IObjectData objData = (IObjectData)clone.Value;
-            //if (objData is ConstrainedDoubleData) {
-            //  ((ConstrainedDoubleData)objData).Data = (double)linearRepresentation[0].localData[localVariableIndex];
-            //} else if (objData is ConstrainedIntData) {
-            //  ((ConstrainedIntData)objData).Data = (int)linearRepresentation[0].localData[localVariableIndex];
-            //} else {
-            //  objData.Data = linearRepresentation[0].localData[localVariableIndex];
-            //}
-            variables.Add(v);
-            //localVariableIndex++;
-          }
-          variablesExpanded = true;
-          linearRepresentation[0].localData.Clear();
-        }
-        return variables;
-      }
-    }
-
-    public IFunction Function {
-      get { return linearRepresentation[0].functionType; }
-    }
-
-    public IVariable GetLocalVariable(string name) {
-      foreach (IVariable var in LocalVariables) {
-        if (var.Name == name) return var;
-      }
-      return null;
-    }
-
-    public void AddVariable(IVariable variable) {
-      if (!variablesExpanded) throw new InvalidOperationException();
-      if (!variables.Exists(v => v.Name == variable.Name))
-        variables.Add(variable);
-    }
-
-    public void RemoveVariable(string name) {
-      if (!variablesExpanded) throw new InvalidOperationException();
-      variables.RemoveAll(v => v.Name == name);
-    }
-
-    public void AddSubTree(IFunctionTree tree) {
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.Add(tree);
-    }
-
-    public void InsertSubTree(int index, IFunctionTree tree) {
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.Insert(index, tree);
-    }
-
-    public void RemoveSubTree(int index) {
-      // sanity check
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.RemoveAt(index);
-    }
-
-    //public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
-    //  FlattenVariables();
-    //  FlattenTrees();
-    //  XmlNode node = base.GetXmlNode(name, document, persistedObjects);
-    //  XmlNode linearRepresentationNode = document.CreateElement("LinearRepresentation");
-    //  foreach (LightWeightFunction f in linearRepresentation) {
-    //    XmlNode entryNode = PersistenceManager.Persist("Function", f.functionType, document, persistedObjects);
-    //    XmlAttribute arityAttribute = document.CreateAttribute("Arity");
-    //    arityAttribute.Value = XmlConvert.ToString(f.arity);
-    //    entryNode.Attributes.Append(arityAttribute);
-    //    foreach (object o in f.localData) {
-    //      if (f.localData.Count > 0) {
-    //        entryNode.AppendChild(CreateDataNode(document, o));
-    //      }
-    //    }
-    //    linearRepresentationNode.AppendChild(entryNode);
-    //  }
-
-    //  node.AppendChild(linearRepresentationNode);
-    //  return node;
-    //}
-
-    private XmlNode CreateDataNode(XmlDocument doc, object o) {
-      XmlNode node = doc.CreateElement("Data");
-      XmlAttribute typeAttr = doc.CreateAttribute("Type");
-      node.Attributes.Append(typeAttr);
-      if (o is double) {
-        node.Value = XmlConvert.ToString((double)o);
-        typeAttr.Value = "d";
-      } else if (o is int) {
-        node.Value = XmlConvert.ToString((int)o);
-        typeAttr.Value = "i";
-      } else if (o is string) {
-        node.Value = (string)o;
-        typeAttr.Value = "s";
-      } else throw new ArgumentException("Invalid type for local data element: " + o);
-      return node;
-    }
-
-    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
-    //  base.Populate(node, restoredObjects);
-    //  XmlNode linearRepresentationNode = node.SelectSingleNode("LinearRepresentation");
-    //  foreach (XmlNode entryNode in linearRepresentationNode.ChildNodes) {
-    //    LightWeightFunction f = new LightWeightFunction();
-    //    f.arity = XmlConvert.ToByte(entryNode.Attributes["Arity"].Value);
-    //    foreach (XmlNode dataNode in entryNode.ChildNodes) {
-    //      f.localData.Add(ParseDataNode(dataNode));
-    //    }
-    //    f.functionType = (IFunction)PersistenceManager.Restore(entryNode, restoredObjects);
-    //    linearRepresentation.Add(f);
-    //  }
-    //  treesExpanded = false;
-    //  variablesExpanded = false;
-    //}
-
-    private object ParseDataNode(XmlNode dataNode) {
-      string type = dataNode.Attributes["Type"].Value;
-      if (type == "d") {
-        return XmlConvert.ToDouble(dataNode.Value);
-      } else if (type == "i") {
-        return XmlConvert.ToInt32(dataNode.Value);
-      } else if (type == "s") {
-        return dataNode.Value;
-      } else throw new FormatException("Can't parse type \"" + type + "\" \"" + dataNode.Value + "\" as local data for GP trees");
-    }
-
-    //private string GetString(IEnumerable<double> xs) {
-    //  StringBuilder builder = new StringBuilder();
-    //  foreach (double x in xs) {
-    //    builder.Append(x.ToString("r", CultureInfo.InvariantCulture) + "; ");
-    //  }
-    //  if (builder.Length > 0) builder.Remove(builder.Length - 2, 2);
-    //  return builder.ToString();
-    //}
-
-    //private List<T> GetList<T>(string s, Converter<string, T> converter) {
-    //  List<T> result = new List<T>();
-    //  string[] tokens = s.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
-    //  foreach (string token in tokens) {
-    //    T x = converter(token.Trim());
-    //    result.Add(x);
-    //  }
-    //  return result;
-    //}
-
-    public override object Clone(IDictionary<Guid, object> clonedObjects) {
-      BakedFunctionTree clone = new BakedFunctionTree();
-      // in case the user (de)serialized the tree between evaluation and selection we have to flatten the tree again.
-      if (treesExpanded) FlattenTrees();
-      if (variablesExpanded) FlattenVariables();
-      foreach (LightWeightFunction f in linearRepresentation) {
-        clone.linearRepresentation.Add(f.Clone());
-      }
-      return clone;
-    }
-
-    public override IView CreateView() {
-      return new FunctionTreeView(this);
-    }
-
-    //public override string ToString() {
-    //  SymbolicExpressionExporter exporter = new SymbolicExpressionExporter();
-    //  exporter.Visit(this);
-    //  return exporter.GetStringRepresentation();
-    //}
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs	(revision 2211)
@@ -30,5 +30,5 @@
     public BinaryFunction()
       : base() {
-      MinArity = 2; MaxArity = 2;
+      MinSubTrees = 2; MaxSubTrees = 2;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs	(revision 2211)
@@ -49,5 +49,5 @@
     }
 
-    public int MinArity {
+    public int MinSubTrees {
       get {
         return minArity;
@@ -59,5 +59,5 @@
     }
 
-    public int MaxArity {
+    public int MaxSubTrees {
       get {
         return maxArity;
@@ -128,5 +128,5 @@
 
     public ICollection<IFunction> GetAllowedSubFunctions(int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      if (index < 0 || index > MaxSubTrees) throw new ArgumentException("Index outside of allowed range. index = " + index);
       //if (allowedSubFunctions == null) {
       //  // first time: analyze the constraint and create a cached copy of the allowed sub-functions
@@ -140,5 +140,5 @@
 
     public void AddAllowedSubFunction(IFunction function, int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      if (index < 0 || index > MaxSubTrees) throw new ArgumentException("Index outside of allowed range. index = " + index);
       if (allowedSubFunctions[index] == null) {
         allowedSubFunctions[index] = new List<IFunction>();
@@ -150,5 +150,5 @@
 
     public void RemoveAllowedSubFunction(IFunction function, int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      if (index < 0 || index > MaxSubTrees) throw new ArgumentException("Index outside of allowed range. index = " + index);
       allowedSubFunctions[index].Add(function);
     }
@@ -190,5 +190,5 @@
       int sum = 1;
       int minSize = int.MaxValue;
-      for (int i = 0; i < MinArity; i++) {
+      for (int i = 0; i < MinSubTrees; i++) {
         foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
           minSize = Math.Min(minSize, subFun.MinTreeSize);
@@ -203,5 +203,5 @@
       int height = 0;
       int minHeight = int.MaxValue;
-      for (int i = 0; i < MinArity; i++) {
+      for (int i = 0; i < MinSubTrees; i++) {
         foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
           minHeight = Math.Min(minHeight, subFun.MinTreeHeight);
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs	(revision 2211)
@@ -31,4 +31,7 @@
     private IFunction function;
 
+    public FunctionTreeBase() {
+    }
+
     public FunctionTreeBase(IFunction function) {
       subTrees = new List<IFunctionTree>();
@@ -49,5 +52,5 @@
     }
 
-    public IList<IFunctionTree> SubTrees {
+    public virtual IList<IFunctionTree> SubTrees {
       get { return subTrees; }
     }
@@ -55,9 +58,12 @@
     public IFunction Function {
       get { return function; }
+      protected set {
+        function = value;
+      }
     }
 
     public int GetSize() {
       int size = 1;
-      foreach (IFunctionTree tree in subTrees) size += tree.GetSize();
+      foreach (IFunctionTree tree in SubTrees) size += tree.GetSize();
       return size;
     }
@@ -65,5 +71,5 @@
     public int GetHeight() {
       int maxHeight = 0;
-      foreach (IFunctionTree tree in subTrees) maxHeight = Math.Max(maxHeight, tree.GetHeight());
+      foreach (IFunctionTree tree in SubTrees) maxHeight = Math.Max(maxHeight, tree.GetHeight());
       return maxHeight + 1;
     }
@@ -78,13 +84,13 @@
 
     public void AddSubTree(IFunctionTree tree) {
-      subTrees.Add(tree);
+      SubTrees.Add(tree);
     }
 
-    public void InsertSubTree(int index, IFunctionTree tree) {
-      subTrees.Insert(index, tree);
+    public virtual void InsertSubTree(int index, IFunctionTree tree) {
+      SubTrees.Insert(index, tree);
     }
 
-    public void RemoveSubTree(int index) {
-      subTrees.RemoveAt(index);
+    public virtual void RemoveSubTree(int index) {
+      SubTrees.RemoveAt(index);
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs	(revision 2211)
@@ -30,5 +30,5 @@
     public Terminal()
       : base() {
-      MinArity = 0; MaxArity = 0;
+      MinSubTrees = 0; MaxSubTrees = 0;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs	(revision 2211)
@@ -30,5 +30,5 @@
     public UnaryFunction()
       : base() {
-      MinArity = 1; MaxArity = 1;
+      MinSubTrees = 1; MaxSubTrees = 1;
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs	(revision 2211)
@@ -136,6 +136,6 @@
       IFunction selectedFunction = allowedFunctions[random.Next(allowedFunctions.Count)];
       // arity of the selected operator
-      int minArity = selectedFunction.MinArity;
-      int maxArity = selectedFunction.MaxArity;
+      int minArity = selectedFunction.MinSubTrees;
+      int maxArity = selectedFunction.MaxSubTrees;
       // if the old child had too many sub-trees then the new child should keep as many sub-trees as possible
       if (actualArity > maxArity)
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs	(revision 2211)
@@ -59,5 +59,5 @@
       // select a branch to prune
       int childIndex = random.Next(parent.SubTrees.Count);
-      if (parent.SubTrees.Count > parent.Function.MinArity) {
+      if (parent.SubTrees.Count > parent.Function.MinSubTrees) {
         parent.RemoveSubTree(childIndex);
         // actually since the next sub-trees are shifted in the place of the removed branch
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs	(revision 2211)
@@ -59,5 +59,5 @@
       // init functions and terminals based on constraints
       foreach(IFunction fun in funLibrary.Functions) {
-        if(fun.MaxArity == 0) {
+        if(fun.MaxSubTrees == 0) {
           terminals.Add(fun);
           allFunctions.Add(fun);
@@ -107,6 +107,6 @@
       int currentSize = 1;
       int totalListMinSize = 0;
-      int minArity = root.Function.MinArity;
-      int maxArity = root.Function.MaxArity;
+      int minArity = root.Function.MinSubTrees;
+      int maxArity = root.Function.MaxSubTrees;
       if (maxArity >= size) {
         maxArity = size;
@@ -142,6 +142,6 @@
           totalListMinSize--;
 
-          minArity = selectedFunction.MinArity;
-          maxArity = selectedFunction.MaxArity;
+          minArity = selectedFunction.MinSubTrees;
+          maxArity = selectedFunction.MaxSubTrees;
           if (maxArity >= size) {
             maxArity = size;
@@ -277,5 +277,5 @@
       }
 
-      if(tree.SubTrees.Count < tree.Function.MinArity || tree.SubTrees.Count > tree.Function.MaxArity)
+      if(tree.SubTrees.Count < tree.Function.MinSubTrees || tree.SubTrees.Count > tree.Function.MaxSubTrees)
         return false;
       foreach(IFunctionTree subTree in tree.SubTrees) {
@@ -306,6 +306,6 @@
 
     private bool IsPossibleParent(IFunction f, List<IFunction> children) {
-      int minArity = f.MinArity;
-      int maxArity = f.MaxArity;
+      int minArity = f.MinSubTrees;
+      int maxArity = f.MaxSubTrees;
       // note: we can't assume that the operators in the children list have different types!
 
@@ -370,5 +370,5 @@
     }
     internal static bool IsTerminal(IFunction f) {
-      return f.MinArity == 0 && f.MaxArity == 0;
+      return f.MinSubTrees == 0 && f.MaxSubTrees == 0;
     }
     internal ICollection<IFunction> GetAllowedSubFunctions(IFunction f, int index) {
@@ -397,6 +397,6 @@
     private IFunctionTree MakeUnbalancedTree(IFunction parent, int maxTreeHeight) {
       if(maxTreeHeight == 0) return parent.GetTreeNode();
-      int minArity = parent.MinArity;
-      int maxArity = parent.MaxArity;
+      int minArity = parent.MinSubTrees;
+      int maxArity = parent.MaxSubTrees;
       int actualArity = random.Next(minArity, maxArity + 1);
       if(actualArity > 0) {
@@ -418,6 +418,6 @@
     private IFunctionTree MakeBalancedTree(IFunction parent, int maxTreeHeight) {
       if(maxTreeHeight == 0) return parent.GetTreeNode();
-      int minArity = parent.MinArity;
-      int maxArity = parent.MaxArity;
+      int minArity = parent.MinSubTrees;
+      int maxArity = parent.MaxSubTrees;
       int actualArity = random.Next(minArity, maxArity + 1);
       if(actualArity > 0) {
