Index: /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs
===================================================================
--- /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs	(revision 7088)
+++ /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs	(revision 7089)
@@ -33,6 +33,5 @@
 
   [Item("ContextAwareCrossover", "An operator which performs subtree swapping in a deterministic way: it checks all possible cross points in the second parent with the aim of creating the best possible offspring.")]
-  public sealed class SymbolicDataAnalysisExpressionContextAwareCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData 
-  {
+  public sealed class SymbolicDataAnalysisExpressionContextAwareCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData {
     [StorableConstructor]
     private SymbolicDataAnalysisExpressionContextAwareCrossover(bool deserializing) : base(deserializing) { }
@@ -45,5 +44,5 @@
     public override IDeepCloneable Clone(Cloner cloner) {
       return new SymbolicDataAnalysisExpressionContextAwareCrossover<T>(this, cloner);
-    } 
+    }
     protected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
       if (this.ExecutionContext == null)
@@ -63,6 +62,6 @@
       List<CutPoint> crossoverPoints0 = new List<CutPoint>();
       parent0.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent0.Root) 
-          foreach (var child in n.Subtrees) 
+        if (n.Subtrees.Any() && n != parent0.Root)
+          foreach (var child in n.Subtrees)
             crossoverPoints0.Add(new CutPoint(n, child));
       });
@@ -73,8 +72,8 @@
       List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
       parent1.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent1.Root) 
+        if (n.Subtrees.Any() && n != parent1.Root)
           foreach (var child in n.Subtrees)
             if (crossoverPoint0.IsMatchingPointType(child) && (child.GetDepth() + level <= maxDepth) && (child.GetLength() + length <= maxLength))
-              allowedBranches.Add(n);
+              allowedBranches.Add(child);
       });
 
@@ -82,5 +81,5 @@
       if (crossoverPoint0.IsMatchingPointType(null)) allowedBranches.Add(null);
 
-      if (allowedBranches.Count == 0) 
+      if (allowedBranches.Count == 0)
         return parent0;
 
@@ -90,5 +89,5 @@
       ISymbolicExpressionTreeNode selectedBranch = null;
 
-      var nodeQualities = new List<Tuple<ISymbolicExpressionTreeNode,double>>();
+      var nodeQualities = new List<Tuple<ISymbolicExpressionTreeNode, double>>();
 
       foreach (var node in allowedBranches) {
Index: /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs
===================================================================
--- /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs	(revision 7088)
+++ /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs	(revision 7089)
@@ -54,5 +54,5 @@
     }
     public ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>> EvaluatorParameter {
-      get { return (ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>>) Parameters[EvaluatorParameterName]; }
+      get { return (ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>>)Parameters[EvaluatorParameterName]; }
     }
     public IValueLookupParameter<IntRange> SymbolicDataAnalysisEvaluationPartitionParameter {
@@ -107,21 +107,23 @@
     /// <param name="startSymbol"></param>
     /// <returns></returns>
-    protected static ISymbolicExpressionTree CreateTreeFromNode(IRandom random, ISymbolicExpressionTreeNode node, ISymbolicExpressionGrammar grammar) {
-      SymbolicExpressionTree tree = new SymbolicExpressionTree();
-      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
-      if (rootNode.HasLocalParameters)
-        rootNode.ResetLocalParameters(random);
-      rootNode.SetGrammar((ISymbolicExpressionTreeGrammar)grammar);
-      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
-      startNode.SetGrammar((ISymbolicExpressionTreeGrammar)grammar);
-      if (startNode.HasLocalParameters)
-        startNode.ResetLocalParameters(random);
+    protected static ISymbolicExpressionTree CreateTreeFromNode(IRandom random, ISymbolicExpressionTreeNode node, ISymbol rootSymbol, ISymbol startSymbol) {
+      var rootNode = new SymbolicExpressionTreeTopLevelNode(rootSymbol);
+      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
+
+      //if (node.Symbol.Name == startSymbol.Name) {
+      //  rootNode.AddSubtree(node);
+      //} else {
+      //  var startNode = new SymbolicExpressionTreeTopLevelNode(startSymbol);
+      //  if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
+
+      //  startNode.AddSubtree(node);
+      //  rootNode.AddSubtree(startNode);
+      //}
+      var startNode = new SymbolicExpressionTreeTopLevelNode(startSymbol);
+      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
+
+      startNode.AddSubtree(node);
       rootNode.AddSubtree(startNode);
 
-      rootNode.AddSubtree(startNode); 
-      if (startNode.Grammar.IsAllowedChildSymbol(startNode.Symbol, node.Symbol))
-        startNode.AddSubtree(node);
-      else
-        throw new InvalidOperationException("The given node cannot be a child of the start symbol.");
       return new SymbolicExpressionTree(rootNode);
     }
Index: /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs
===================================================================
--- /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs	(revision 7088)
+++ /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs	(revision 7089)
@@ -33,6 +33,5 @@
 
   [Item("DepthConstrainedCrossover", "An operator which performs subtree swapping only within a specific depth range.")]
-  public sealed class SymbolicDataAnalysisExpressionDepthConstrainedCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData 
-  {
+  public sealed class SymbolicDataAnalysisExpressionDepthConstrainedCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData {
     [StorableConstructor]
     private SymbolicDataAnalysisExpressionDepthConstrainedCrossover(bool deserializing) : base(deserializing) { }
@@ -41,5 +40,5 @@
     public SymbolicDataAnalysisExpressionDepthConstrainedCrossover() : base() { }
     public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionDepthConstrainedCrossover<T>(this, cloner); }
- 
+
     protected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
@@ -56,6 +55,6 @@
       List<CutPoint> crossoverPoints0 = new List<CutPoint>();
       parent0.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent0.Root) 
-          foreach (var child in n.Subtrees) 
+        if (n.Subtrees.Any() && n != parent0.Root)
+          foreach (var child in n.Subtrees)
             crossoverPoints0.Add(new CutPoint(n, child));
       });
@@ -66,8 +65,8 @@
       List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
       parent1.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent1.Root) 
+        if (n.Subtrees.Any() && n != parent1.Root)
           foreach (var child in n.Subtrees)
             if (crossoverPoint0.IsMatchingPointType(child) && (child.GetDepth() + level <= maxDepth) && (child.GetLength() + length <= maxLength))
-              allowedBranches.Add(n);
+              allowedBranches.Add(child);
       });
 
@@ -75,5 +74,5 @@
       if (crossoverPoint0.IsMatchingPointType(null)) allowedBranches.Add(null);
 
-      if (allowedBranches.Count == 0) 
+      if (allowedBranches.Count == 0)
         return parent0;
 
Index: /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs
===================================================================
--- /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs	(revision 7088)
+++ /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs	(revision 7089)
@@ -33,13 +33,12 @@
 
   [Item("ProbabilisticFunctionalCrossover", "An operator which performs subtree swapping based on behavioral similarity")]
-  public sealed class SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData 
-  {
+  public sealed class SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData {
     [StorableConstructor]
     private SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover(bool deserializing) : base(deserializing) { }
-    private SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover(SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T> original, Cloner cloner) 
+    private SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover(SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T> original, Cloner cloner)
       : base(original, cloner) { }
     public SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover() : base() { }
     public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T>(this, cloner); }
- 
+
     protected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
@@ -47,5 +46,5 @@
       T problemData = ProblemDataParameter.ActualValue;
       var grammar = parent0.Root.Grammar;
-      return Cross(random, parent0, parent1, interpreter, problemData, 
+      return Cross(random, parent0, parent1, interpreter, problemData,
                    rows, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value);
     }
@@ -58,10 +57,10 @@
     /// choose the second crosspoint via a random weighted selection procedure.
     /// </summary>
-    public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1, 
+    public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1,
                                                 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, T problemData, IEnumerable<int> rows, int maxDepth, int maxLength) {
       List<CutPoint> crossoverPoints0 = new List<CutPoint>();
       parent0.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent0.Root) 
-          foreach (var child in n.Subtrees) 
+        if (n.Subtrees.Any() && n != parent0.Root)
+          foreach (var child in n.Subtrees)
             crossoverPoints0.Add(new CutPoint(n, child));
       });
@@ -72,8 +71,8 @@
       List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
       parent1.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent1.Root) 
+        if (n.Subtrees.Any() && n != parent1.Root)
           foreach (var child in n.Subtrees)
             if (crossoverPoint0.IsMatchingPointType(child) && (child.GetDepth() + level <= maxDepth) && (child.GetLength() + length <= maxLength))
-              allowedBranches.Add(n);
+              allowedBranches.Add(child);
       });
 
@@ -81,5 +80,5 @@
       if (crossoverPoint0.IsMatchingPointType(null)) allowedBranches.Add(null);
 
-      if (allowedBranches.Count == 0) 
+      if (allowedBranches.Count == 0)
         return parent0;
 
@@ -87,5 +86,7 @@
 
       // create symbols in order to improvize an ad-hoc tree so that the child can be evaluated
-      var tree0 = CreateTreeFromNode(random, crossoverPoint0.Child, (ISymbolicExpressionGrammar)parent0.Root.Grammar);
+      var rootSymbol = new ProgramRootSymbol();
+      var startSymbol = new StartSymbol();
+      var tree0 = CreateTreeFromNode(random, crossoverPoint0.Child, rootSymbol, startSymbol);
       IEnumerable<double> estimatedValues0 = interpreter.GetSymbolicExpressionTreeValues(tree0, dataset, rows);
       double min0 = estimatedValues0.Min();
@@ -94,5 +95,5 @@
       List<double> weights = new List<double>();
       foreach (var node in allowedBranches) {
-        var tree1 = CreateTreeFromNode(random, node, (ISymbolicExpressionGrammar)parent0.Root.Grammar);
+        var tree1 = CreateTreeFromNode(random, node, rootSymbol, startSymbol);
         IEnumerable<double> estimatedValues1 = interpreter.GetSymbolicExpressionTreeValues(tree1, dataset, rows);
         double min1 = estimatedValues1.Min();
@@ -133,6 +134,6 @@
       double r = weights.Sum() * random.NextDouble();
       for (int i = 0; i != nodes.Count; ++i) {
-        if (r < weights[i]) 
-          return nodes[i];        
+        if (r < weights[i])
+          return nodes[i];
         r -= weights[i];
       }
Index: /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs
===================================================================
--- /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs	(revision 7088)
+++ /branches/gp-crossover/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs	(revision 7089)
@@ -33,6 +33,5 @@
 
   [Item("SemanticSimilarityCrossover", "An operator which performs subtree swapping based on semantic similarity.")]
-  public sealed class SymbolicDataAnalysisExpressionSemanticSimilarityCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData 
-  {
+  public sealed class SymbolicDataAnalysisExpressionSemanticSimilarityCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData {
     [StorableConstructor]
     private SymbolicDataAnalysisExpressionSemanticSimilarityCrossover(bool deserializing) : base(deserializing) { }
@@ -40,5 +39,5 @@
     public SymbolicDataAnalysisExpressionSemanticSimilarityCrossover() : base() { }
     public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionSemanticSimilarityCrossover<T>(this, cloner); }
- 
+
     protected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {
       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
@@ -51,10 +50,10 @@
     /// Randomly choose a node i from the first parent, then get a node j from the second parent that matches the semantic similarity criteria.
     /// </summary>
-    public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1, 
+    public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1,
                                                 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, T problemData, IEnumerable<int> rows, int maxDepth, int maxLength) {
       List<CutPoint> crossoverPoints0 = new List<CutPoint>();
       parent0.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent0.Root) 
-          foreach (var child in n.Subtrees) 
+        if (n.Subtrees.Any() && n != parent0.Root)
+          foreach (var child in n.Subtrees)
             crossoverPoints0.Add(new CutPoint(n, child));
       });
@@ -65,8 +64,8 @@
       List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
       parent1.Root.ForEachNodePostfix((n) => {
-        if (n.Subtrees.Any() && n != parent1.Root) 
+        if (n.Subtrees.Any() && n != parent1.Root)
           foreach (var child in n.Subtrees)
             if (crossoverPoint0.IsMatchingPointType(child) && (child.GetDepth() + level <= maxDepth) && (child.GetLength() + length <= maxLength))
-              allowedBranches.Add(n);
+              allowedBranches.Add(child);
       });
 
@@ -74,5 +73,5 @@
       if (crossoverPoint0.IsMatchingPointType(null)) allowedBranches.Add(null);
 
-      if (allowedBranches.Count == 0) 
+      if (allowedBranches.Count == 0)
         return parent0;
 
@@ -80,7 +79,7 @@
 
       // create symbols in order to improvize an ad-hoc tree so that the child can be evaluated
-      //var rootSymbol = new ProgramRootSymbol();
-      //var startSymbol = new StartSymbol();
-      var tree0 = CreateTreeFromNode(random, crossoverPoint0.Child, (ISymbolicExpressionGrammar)parent0.Root.Grammar);
+      var rootSymbol = new ProgramRootSymbol();
+      var startSymbol = new StartSymbol();
+      var tree0 = CreateTreeFromNode(random, crossoverPoint0.Child, rootSymbol, startSymbol);
       IEnumerable<double> estimatedValues0 = interpreter.GetSymbolicExpressionTreeValues(tree0, dataset, rows);
 
@@ -89,5 +88,5 @@
       // pick the first node that fulfills the semantic similarity conditions
       foreach (var node in allowedBranches) {
-        var tree1 = CreateTreeFromNode(random, node, (ISymbolicExpressionGrammar)parent0.Root.Grammar);
+        var tree1 = CreateTreeFromNode(random, node, startSymbol, rootSymbol);
         IEnumerable<double> estimatedValues1 = interpreter.GetSymbolicExpressionTreeValues(tree1, dataset, rows);
 
