Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/And.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/And.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/And.cs	(revision 147)
@@ -43,7 +43,7 @@
 
     // special form
-    public override double Evaluate(Dataset dataset, int sampleIndex, IList<IFunctionTree> subFunctions) {
-      foreach(IFunctionTree subFunction in subFunctions) {
-        double result = Math.Round(subFunction.Evaluate(dataset, sampleIndex));
+    public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      foreach(IFunctionTree subTree in tree.SubTrees) {
+        double result = Math.Round(subTree.Evaluate(dataset, sampleIndex));
         if(result == 0.0) return 0.0; // one sub-tree is 0.0 (false) => return false
         else if(result != 1.0) return double.NaN;
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs	(revision 147)
@@ -37,11 +37,4 @@
     }
 
-    private ConstrainedDoubleData value;
-    public ConstrainedDoubleData Value {
-      get {
-        return value;
-      }
-    }
-
     public Constant()
       : base() {
@@ -52,6 +45,4 @@
       // initialize a default range for the contant value
       valueData.AddConstraint(new DoubleBoundedConstraint(-20.0, 20.0));
-
-      // create the local variable
       HeuristicLab.Core.Variable value = new HeuristicLab.Core.Variable(VALUE, valueData);
       AddVariable(value);
@@ -61,17 +52,12 @@
     }
 
-    public override object Clone(IDictionary<Guid, object> clonedObjects) {
-      Constant clone = (Constant)base.Clone(clonedObjects);
-      clone.value = (ConstrainedDoubleData)clone.GetVariable(VALUE).Value;
-      return clone;
+    // constant is evaluated directly. Evaluation reads the local variable value from the tree and returns
+    public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      return ((ConstrainedDoubleData)tree.GetLocalVariable(VALUE).Value).Data;
     }
 
-    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
-      base.Populate(node, restoredObjects);
-      value = (ConstrainedDoubleData)GetVariable(VALUE).Value;
-    }
-
+    // can't apply a constant
     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
-      return value.Data;
+      throw new NotSupportedException();
     }
 
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionBase.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionBase.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionBase.cs	(revision 147)
@@ -35,9 +35,9 @@
   public abstract class FunctionBase : OperatorBase, IFunction {
     
-    public virtual double Evaluate(Dataset dataset, int sampleIndex, IList<IFunctionTree> subTrees) {
-      if(subTrees.Count > 0) {
-        double[] evaluationResults = new double[subTrees.Count];
+    public virtual double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      if(tree.SubTrees.Count > 0) {
+        double[] evaluationResults = new double[tree.SubTrees.Count];
         for(int i = 0; i < evaluationResults.Length; i++) {
-          evaluationResults[i] = subTrees[i].Evaluate(dataset, sampleIndex);
+          evaluationResults[i] = tree.SubTrees[i].Evaluate(dataset, sampleIndex);
         }
         return Apply(dataset, sampleIndex, evaluationResults);
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionTree.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionTree.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionTree.cs	(revision 147)
@@ -71,5 +71,5 @@
 
     public double Evaluate(Dataset dataset, int sampleIndex) {
-      return function.Evaluate(dataset, sampleIndex, subTrees);
+      return function.Evaluate(dataset, sampleIndex, this);
     }
     #endregion
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IFunction.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IFunction.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IFunction.cs	(revision 147)
@@ -28,5 +28,5 @@
 namespace HeuristicLab.Functions {
   public interface IFunction : IOperator {
-    double Evaluate(Dataset dataset, int sampleIndex, IList<IFunctionTree> subTrees);
+    double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree);
     double Apply(Dataset dataset, int sampleIndex, double[] args);
     void Accept(IFunctionVisitor visitor);
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IfThenElse.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IfThenElse.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/IfThenElse.cs	(revision 147)
@@ -42,8 +42,8 @@
 
     // special form
-    public override double Evaluate(Dataset dataset, int sampleIndex, IList<IFunctionTree> subTrees) {
-      double condition = Math.Round(subTrees[0].Evaluate(dataset, sampleIndex));
-      if(condition < .5) return subTrees[1].Evaluate(dataset, sampleIndex);
-      else if(condition >= .5) return subTrees[2].Evaluate(dataset, sampleIndex);
+    public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      double condition = Math.Round(tree.SubTrees[0].Evaluate(dataset, sampleIndex));
+      if(condition < .5) return tree.SubTrees[1].Evaluate(dataset, sampleIndex);
+      else if(condition >= .5) return tree.SubTrees[2].Evaluate(dataset, sampleIndex);
       else return double.NaN;
     }
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Or.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Or.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Or.cs	(revision 147)
@@ -41,6 +41,6 @@
     }
 
-    public override double Evaluate(Dataset dataset, int sampleIndex, IList<IFunctionTree> subTrees) {
-      foreach(IFunctionTree subTree in subTrees) {
+    public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      foreach(IFunctionTree subTree in tree.SubTrees) {
         double result = Math.Round(subTree.Evaluate(dataset, sampleIndex));
         if(result == 1.0) return 1.0; // sub-tree evaluates to 1.0 (true) return 1.0
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs	(revision 146)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs	(revision 147)
@@ -36,20 +36,4 @@
     public static readonly string INDEX = "Variable";
 
-    private ConstrainedIntData variable;
-    private ConstrainedDoubleData weight;
-    private ConstrainedIntData sampleOffset;
-
-    public double SampleOffset {
-      get { return sampleOffset.Data; }
-    }
-
-    public int VariableIndex {
-      get { return variable.Data; }
-    }
-
-    public double Weight {
-      get { return weight.Data; }
-    }
-
     public override string Description {
       get { return @"Variable reads a value from a dataset, multiplies that value with a given factor and returns the result.
@@ -67,44 +51,35 @@
       GetVariableInfo(OFFSET).Local = true;
 
-      variable = new ConstrainedIntData();
-      AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
-
-      weight = new ConstrainedDoubleData();
+      ConstrainedDoubleData weight = new ConstrainedDoubleData();
       // initialize a totally arbitrary range for the weight = [-20.0, 20.0]
       weight.AddConstraint(new DoubleBoundedConstraint(-20.0, 20.0));
       AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));
 
-      sampleOffset = new ConstrainedIntData();
+      ConstrainedIntData variable = new ConstrainedIntData();
+      AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
+
+      ConstrainedIntData sampleOffset = new ConstrainedIntData();
       // initialize a totally arbitrary default range for sampleoffset = [-10, 10]
       sampleOffset.AddConstraint(new IntBoundedConstraint(0, 0));
       AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset));
 
-      // samplefeature can't have suboperators
+      // variable can't have suboperators
       AddConstraint(new NumberOfSubOperatorsConstraint(0, 0));
     }
 
-    public override object Clone(IDictionary<Guid, object> clonedObjects) {
-      HeuristicLab.Functions.Variable clone = (HeuristicLab.Functions.Variable)base.Clone(clonedObjects);
-      clone.variable = (ConstrainedIntData)clone.GetVariable(INDEX).Value;
-      clone.weight = (ConstrainedDoubleData)clone.GetVariable(WEIGHT).Value;
-      clone.sampleOffset = (ConstrainedIntData)clone.GetVariable(OFFSET).Value;
-      return clone;
-    }
-    
-    public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
-      base.Populate(node, restoredObjects);
-      variable = (ConstrainedIntData)GetVariable(INDEX).Value;
-      weight = (ConstrainedDoubleData)GetVariable(WEIGHT).Value;
-      sampleOffset = (ConstrainedIntData)GetVariable(OFFSET).Value;
+    // variable can be evaluated directly
+    // evaluation reads local variables weight, index, offset from function-tree and returns the variable-value * weight
+    public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) {
+      double w = ((ConstrainedDoubleData)tree.GetLocalVariable(WEIGHT).Value).Data;
+      int v = ((ConstrainedIntData)tree.GetLocalVariable(INDEX).Value).Data;
+      int offset = ((ConstrainedIntData)tree.GetLocalVariable(OFFSET).Value).Data;
+
+      if(sampleIndex + offset < 0 || sampleIndex + offset >= dataset.Rows) return double.NaN;
+      return w * dataset.GetValue(sampleIndex + offset, v);
     }
 
+    // can't apply a variable
     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
-      // local variables
-      int v = variable.Data;
-      double w = weight.Data;
-      int offset = sampleOffset.Data;
-
-      if(sampleIndex+offset<0 || sampleIndex+offset>=dataset.Rows) return double.NaN;
-      return w * dataset.GetValue(sampleIndex + offset, v);
+      throw new NotSupportedException();
     }
 
