Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs	(revision 9083)
@@ -88,5 +88,5 @@
 
     [StorableConstructor]
-    private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base() { }
+    private SymbolicExpressionTreeLengthAnalyzer(bool deserializing) : base(deserializing) { }
     private SymbolicExpressionTreeLengthAnalyzer(SymbolicExpressionTreeLengthAnalyzer original, Cloner cloner)
       : base(original, cloner) {
@@ -153,5 +153,5 @@
         // if the table was not created yet, we create it here
         if (treeLengthsTable == null) {
-          treeLengthsTable = new DataTable("Histogram");
+          treeLengthsTable = new DataTable("Tree Length Histogram");
           SymbolicExpressionTreeLengthsParameter.ActualValue = treeLengthsTable;
         }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs	(revision 9083)
@@ -139,4 +139,14 @@
       // the grammar in the newly defined function is a clone of the grammar of the originating branch
       defunNode.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBody.Grammar.Clone());
+
+      var allowedChildSymbols = selectedBody.Grammar.GetAllowedChildSymbols(selectedBody.Symbol);
+      foreach (var allowedChildSymbol in allowedChildSymbols)
+        defunNode.Grammar.AddAllowedChildSymbol(defunNode.Symbol, allowedChildSymbol);
+      var maxSubtrees = selectedBody.Grammar.GetMaximumSubtreeCount(selectedBody.Symbol);
+      for (int i = 0; i < maxSubtrees; i++) {
+        foreach (var allowedChildSymbol in selectedBody.Grammar.GetAllowedChildSymbols(selectedBody.Symbol, i))
+          defunNode.Grammar.AddAllowedChildSymbol(defunNode.Symbol, allowedChildSymbol);
+      }
+
       // remove all argument symbols from grammar except that one contained in cutpoints
       var oldArgumentSymbols = selectedBody.Grammar.Symbols.OfType<Argument>().ToList();
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs	(revision 9083)
@@ -73,4 +73,14 @@
       symbolicExpressionTree.Root.AddSubtree(duplicatedDefunBranch);
       duplicatedDefunBranch.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBranch.Grammar.Clone());
+
+      var allowedChildSymbols = selectedBranch.Grammar.GetAllowedChildSymbols(selectedBranch.Symbol);
+      foreach (var allowedChildSymbol in allowedChildSymbols)
+        duplicatedDefunBranch.Grammar.AddAllowedChildSymbol(duplicatedDefunBranch.Symbol, allowedChildSymbol);
+      var maxSubtrees = selectedBranch.Grammar.GetMaximumSubtreeCount(selectedBranch.Symbol);
+      for (int i = 0; i < maxSubtrees; i++) {
+        foreach (var allowedChildSymbol in selectedBranch.Grammar.GetAllowedChildSymbols(selectedBranch.Symbol, i))
+          duplicatedDefunBranch.Grammar.AddAllowedChildSymbol(duplicatedDefunBranch.Symbol, allowedChildSymbol);
+      }
+
       // add an invoke symbol for each branch that is allowed to invoke the original function
       foreach (var subtree in symbolicExpressionTree.Root.Subtrees.OfType<SymbolicExpressionTreeTopLevelNode>()) {
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs	(revision 9083)
@@ -25,14 +25,15 @@
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  public class SymbolicExpressionTreeCompiler {
-    private Dictionary<string, ushort> entryPoint = new Dictionary<string, ushort>();
-    private List<Func<Instruction, Instruction>> postInstructionCompiledHooks = new List<Func<Instruction, Instruction>>();
+  public static class SymbolicExpressionTreeCompiler {
 
-    public Instruction[] Compile(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
+    public static Instruction[] Compile(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
+      return Compile(tree, opCodeMapper, Enumerable.Empty<Func<Instruction, Instruction>>());
+    }
+    public static Instruction[] Compile(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper, IEnumerable<Func<Instruction, Instruction>> postInstructionCompiledHooks) {
+      Dictionary<string, ushort> entryPoint = new Dictionary<string, ushort>();
       List<Instruction> code = new List<Instruction>();
-      entryPoint.Clear();
       // compile main body branches
       foreach (var branch in tree.Root.GetSubtree(0).Subtrees) {
-        code.AddRange(Compile(branch, opCodeMapper));
+        code.AddRange(Compile(branch, opCodeMapper, postInstructionCompiledHooks));
       }
       // compile function branches
@@ -43,5 +44,5 @@
         if (code.Count > ushort.MaxValue) throw new ArgumentException("Code for the tree is too long (> ushort.MaxValue).");
         entryPoint[branch.FunctionName] = (ushort)code.Count;
-        code.AddRange(Compile(branch.GetSubtree(0), opCodeMapper));
+        code.AddRange(Compile(branch.GetSubtree(0), opCodeMapper, postInstructionCompiledHooks));
       }
       // address of all functions is fixed now
@@ -52,5 +53,4 @@
           var invokeNode = (InvokeFunctionTreeNode)instr.dynamicNode;
           instr.iArg0 = entryPoint[invokeNode.Symbol.FunctionName];
-          code[i] = instr;
         }
       }
@@ -59,5 +59,5 @@
     }
 
-    private IEnumerable<Instruction> Compile(ISymbolicExpressionTreeNode branch, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper) {
+    private static IEnumerable<Instruction> Compile(ISymbolicExpressionTreeNode branch, Func<ISymbolicExpressionTreeNode, byte> opCodeMapper, IEnumerable<Func<Instruction, Instruction>> postInstructionCompiledHooks) {
       foreach (var node in branch.IterateNodesPrefix()) {
         Instruction instr = new Instruction();
@@ -77,13 +77,4 @@
       }
     }
-
-    /// <summary>
-    /// Adds a function that will be called every time an instruction is compiled.
-    /// The compiled will insert the instruction returned by the hook into the code.
-    /// </summary>
-    /// <param name="hook">The hook that should be called for each compiled instruction.</param>
-    public void AddInstructionPostProcessingHook(Func<Instruction, Instruction> hook) {
-      postInstructionCompiledHooks.Add(hook);
-    }
   }
 }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs	(revision 9083)
@@ -33,5 +33,5 @@
   [StorableClass]
   [Item("FullTreeCreator", "An operator that creates new symbolic expression trees using the 'Full' method")]
-  public class FullTreeCreator : TracingSymbolicExpressionTreeCreator,
+  public class FullTreeCreator : SymbolicExpressionTreeCreator,
                                  ISymbolicExpressionTreeSizeConstraintOperator,
                                  ISymbolicExpressionTreeGrammarBasedOperator {
@@ -147,4 +147,5 @@
         throw new ArgumentException("Cannot create trees of depth " + maxDepth + " or smaller because of grammar constraints.", "maxDepth");
 
+
       int arity = seedNode.Grammar.GetMaximumSubtreeCount(seedNode.Symbol);
       // Throw an exception if the seedNode happens to be a terminal, since in this case we cannot grow a tree.
@@ -160,5 +161,5 @@
           .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
           .ToList();
-        var weights = possibleSymbols.Select(s => s.InitialFrequency);
+        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
         var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
         var tree = selectedSymbol.CreateTreeNode();
@@ -192,5 +193,5 @@
         if (!possibleSymbols.Any())
           throw new InvalidOperationException("No symbols are available for the tree.");
-        var weights = possibleSymbols.Select(s => s.InitialFrequency);
+        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
         var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
         var tree = selectedSymbol.CreateTreeNode();
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs	(revision 9083)
@@ -160,5 +160,5 @@
           .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
           .ToList();
-        var weights = possibleSymbols.Select(s => s.InitialFrequency);
+        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
         var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
         var tree = selectedSymbol.CreateTreeNode();
@@ -179,7 +179,5 @@
         throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
 
-      var allowedSymbols = root.Grammar.AllowedSymbols
-        .Where(s => s.InitialFrequency > 0.0)
-        .ToList();
+      var allowedSymbols = root.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList();
 
       for (var i = 0; i < arity; i++) {
@@ -188,7 +186,8 @@
             root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth)
           .ToList();
+
         if (!possibleSymbols.Any())
           throw new InvalidOperationException("No symbols are available for the tree.");
-        var weights = possibleSymbols.Select(s => s.InitialFrequency);
+        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
         var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
         var tree = selectedSymbol.CreateTreeNode();
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs	(revision 9083)
@@ -176,6 +176,7 @@
         extensionPoints.Add(x);
       }
-      long minExtensionPointsLength = extensionPoints.Select(x => x.MinimumExtensionLength).Sum();
-      long maxExtensionPointsLength = extensionPoints.Select(x => x.MaximumExtensionLength).Sum();
+      //necessary to use long data type as the extension point length could be int.MaxValue
+      long minExtensionPointsLength = extensionPoints.Select(x => (long)x.MinimumExtensionLength).Sum();
+      long maxExtensionPointsLength = extensionPoints.Select(x => (long)x.MaximumExtensionLength).Sum();
 
       // while there are pending extension points and we have not reached the limit of adding new extension points
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs	(revision 9083)
@@ -32,5 +32,5 @@
   [Item("SymbolicExpressionTreeCrossover", "A base class for operators that perform a crossover of symbolic expression trees.")]
   [StorableClass]
-  public abstract class SymbolicExpressionTreeCrossover : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCrossover {
+  public abstract class SymbolicExpressionTreeCrossover : TracingSymbolicExpressionTreeOperator, ISymbolicExpressionTreeCrossover {
     private const string ParentsParameterName = "Parents";
     private const string ChildParameterName = "Child";
@@ -59,4 +59,6 @@
       Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
       Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
+      ParentsParameter.ActualName = "SymbolicExpressionTree";
+      ChildParameter.ActualName = "SymbolicExpressionTree";
     }
 
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs	(revision 9083)
@@ -24,5 +24,4 @@
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HeuristicLab.EvolutionaryTracking;
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
@@ -37,5 +36,4 @@
     private const string ParentsParameterName = "Parents";
     private const string ChildParameterName = "Child";
-
 
     #region Parameter Properties
@@ -90,7 +88,12 @@
       while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i;
 
-      // add heredity information into the global variables
-      GlobalTraceMap[Child] = new ItemList<IItem>(Parents.Select(x => GlobalCloneMap[x])); ; // map child to its corresponding parents from the previous generation
-      GlobalFragmentMap[Child] = new GenericWrapper<ISymbolicExpressionTreeNode>(i == min ? null : nodes1[i]); // map child to the index of its fragment
+      // map child to its corresponding parents from the previous generation
+      GlobalTraceMap[Child] = new ItemList<IItem>(from p in Parents select GlobalCloneMap[p]);
+      var fragment0 = new Fragment(i == min ? null : nodes0[i]); // fragment replaced in Parent0
+      var fragment1 = new Fragment(i == min ? null : nodes1[i]); // fragment received from Parent1
+      GlobalFragmentMap[Child] = fragment1; // map child to the index of its fragment
+      // transaction.FragmentIn = the fragment received from the other parent
+      // transaction.FragmentOut = the fragment that got replaced
+      GlobalGeneticExchangeMap.Add(new GeneticExchange { FragmentIn = fragment1, FragmentOut = fragment0 });
       return base.Apply();
     }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs	(revision 9083)
@@ -64,29 +64,4 @@
       }
     }
-
-    //public static CutPoint GetCutPoint(ISymbolicExpressionTree parent, ISymbolicExpressionTree child) {
-    //  return GetCutPoint(parent.Root, child.Root);
-    //}
-
-    //public static CutPoint GetCutPoint(ISymbolicExpressionTree parent, ISymbolicExpressionTreeNode child) {
-    //  return GetCutPoint(parent.Root, child);
-    //}
-
-    //public static CutPoint GetCutPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTree child) {
-    //  return GetCutPoint(parent, child.Root);
-    //}
-
-    // child is the result of a genetic operation on parent
-    // this method returns the index on which the two individuals start to differ
-    //public static CutPoint GetCutPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
-    //  var e1 = parent.IterateNodesPostfix().GetEnumerator();
-    //  var e2 = child.IterateNodesPostfix().GetEnumerator();
-    //  int pos = -1;
-    //  var comparer = new SymbolicExpressionTreeNodeSimilarityComparer((int)SymbolicExpressionTreeMatching.SimilarityLevel.Exact);
-    //  while (e1.MoveNext() && e2.MoveNext())
-    //    if (comparer.Equals(e1.Current, e2.Current))
-    //      ++pos;
-    //  return pos == -1 ? null : new CutPoint(parent, pos);
-    //}
   }
 }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs	(revision 9083)
@@ -20,8 +20,8 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using HeuristicLab.Core;
-using System;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Fragment.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Fragment.cs	(revision 9083)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Fragment.cs	(revision 9083)
@@ -0,0 +1,64 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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 HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
+  [Item("Fragment", "Class that represents a tree fragment")]
+  [StorableClass]
+  public class Fragment : Item, IFragment {
+    public ISymbolicExpressionTreeNode Root { get; set; }
+    private int length = -1;
+    public int Length {
+      get {
+        if (Root == null) return 0;
+        if (length == -1) length = Root.GetLength();
+        return length;
+      }
+      set { length = value; }
+    }
+
+    [StorableConstructor]
+    private Fragment(bool serializing) : base(serializing) { }
+    private Fragment(Fragment original, Cloner cloner)
+      : base(original, cloner) {
+      // avoid deep copy of the symbolic expression tree node
+      Root = original.Root;
+      length = original.Length;
+    }
+
+    public Fragment(ISymbolicExpressionTreeNode node) {
+      Root = node;
+      length = (node == null) ? 0 : node.GetLength();
+    }
+
+    public Fragment(ISymbolicExpressionTreeNode node, int length) {
+      Root = node;
+      this.length = length;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new Fragment(this, cloner);
+    }
+  }
+}
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GenericWrapper.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GenericWrapper.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GenericWrapper.cs	(revision 9083)
@@ -6,5 +6,5 @@
   [Item("Generic wrapper", "Wrapper class for non-item HeuristicLab objects")]
   [StorableClass]
-  public class GenericWrapper<T> : NamedItem where T : class, IDeepCloneable {
+  public class GenericWrapper<T> : Item where T : class, IDeepCloneable {
     [Storable]
     public T Content { get; private set; }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GeneticExchange.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GeneticExchange.cs	(revision 9083)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/GeneticExchange.cs	(revision 9083)
@@ -0,0 +1,40 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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 HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
+  [Item("GeneticExchange", "Class that represents a genetic transaction (the exchange of genetic material between two individuals)")]
+  [StorableClass]
+  public class GeneticExchange : Item {
+    public IFragment FragmentIn { get; set; }
+    public IFragment FragmentOut { get; set; }
+
+    [StorableConstructor]
+    private GeneticExchange(bool serializing) : base(serializing) { }
+    private GeneticExchange(GeneticExchange original, Cloner cloner) : base(original, cloner) { }
+    public GeneticExchange() { }
+
+    public override IDeepCloneable Clone(Cloner cloner) { return new GeneticExchange(this, cloner); }
+  }
+}
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj	(revision 9083)
@@ -167,4 +167,7 @@
     <Compile Include="Compiler\SymbolicExpressionTreeCompiler.cs" />
     <None Include="Plugin.cs.frame" />
+    <Compile Include="GeneticExchange.cs" />
+    <Compile Include="Fragment.cs" />
+    <Compile Include="Interfaces\IFragment.cs" />
     <Compile Include="Interfaces\Operators\ITracingSymbolicExpressionTreeOperator.cs" />
     <Compile Include="TracingSymbolicExpressionTreeOperator.cs" />
@@ -264,5 +267,5 @@
   -->
   <PropertyGroup>
-    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
 set ProjectDir=$(ProjectDir)
 set SolutionDir=$(SolutionDir)
@@ -271,4 +274,10 @@
 call PreBuildEvent.cmd
 </PreBuildEvent>
+    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+export ProjectDir=$(ProjectDir)
+export SolutionDir=$(SolutionDir)
+
+$SolutionDir/PreBuildEvent.sh
+</PreBuildEvent>
   </PropertyGroup>
 </Project>
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user	(revision 9083)
@@ -8,4 +8,5 @@
     <StartAction>Program</StartAction>
     <StartProgram>C:\Users\bburlacu\Projects\HeuristicLab\Trunk\sources\bin\HeuristicLab 3.3.exe</StartProgram>
+    <StartArguments>/start:Optimizer /hideStarter</StartArguments>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/IFragment.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/IFragment.cs	(revision 9083)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/IFragment.cs	(revision 9083)
@@ -0,0 +1,28 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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 HeuristicLab.Core;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
+  public interface IFragment : IItem {
+    ISymbolicExpressionTreeNode Root { get; set; }
+    int Length { get; set; }
+  }
+}
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs	(revision 9083)
@@ -29,7 +29,7 @@
     int Depth { get; }
 
+    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth();
     IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix();
     IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix();
-    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth();
   }
 }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs	(revision 9083)
@@ -34,9 +34,9 @@
     int GetBranchLevel(ISymbolicExpressionTreeNode child);
 
+    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth();
     IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix();
     IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix();
-    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth();
+    void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a);
     void ForEachNodePostfix(Action<ISymbolicExpressionTreeNode> a);
-    void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a);
 
     IEnumerable<ISymbolicExpressionTreeNode> Subtrees { get; }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs	(revision 9083)
@@ -24,4 +24,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Collections.Generic;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
@@ -29,4 +30,6 @@
   [Item("ChangeNodeTypeManipulation", "Selects a random tree node and changes the symbol.")]
   public sealed class ChangeNodeTypeManipulation : TracingSymbolicExpressionTreeManipulator {
+    private const int MAX_TRIES = 100;
+
     [StorableConstructor]
     private ChangeNodeTypeManipulation(bool deserializing) : base(deserializing) { }
@@ -43,41 +46,50 @@
 
     public static void ChangeNodeType(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
-      // select any node as parent (except the root node)
-      var manipulationPoints = (from parent in symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1)
-                                let subtreeCount = parent.Subtrees.Count()
-                                from subtreeIndex in Enumerable.Range(0, subtreeCount)
-                                let subtree = parent.GetSubtree(subtreeIndex)
-                                let existingSubtreeCount = subtree.Subtrees.Count()
-                                // find possible symbols for the node (also considering the existing branches below it)
-                                let allowedSymbols = (from symbol in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, subtreeIndex)
-                                                      // do not replace the existing symbol with itself
-                                                      where symbol.Name != subtree.Symbol.Name
-                                                      where symbol.InitialFrequency > 0
-                                                      where existingSubtreeCount <= parent.Grammar.GetMaximumSubtreeCount(symbol)
-                                                      where existingSubtreeCount >= parent.Grammar.GetMinimumSubtreeCount(symbol)
-                                                      // keep only symbols that are still possible considering the existing sub-trees
-                                                      where (from existingSubtreeIndex in Enumerable.Range(0, existingSubtreeCount)
-                                                             let existingSubtree = subtree.GetSubtree(existingSubtreeIndex)
-                                                             select parent.Grammar.IsAllowedChildSymbol(symbol, existingSubtree.Symbol, existingSubtreeIndex))
-                                                             .All(x => x == true)
-                                                      select symbol)
-                                                      .ToList()
-                                where allowedSymbols.Count() > 0
-                                select new { Parent = parent, Child = subtree, Index = subtreeIndex, AllowedSymbols = allowedSymbols })
-                               .ToList();
-      if (manipulationPoints.Count == 0) { return; }
-      var selectedManipulationPoint = manipulationPoints.SelectRandom(random);
+      List<ISymbol> allowedSymbols = new List<ISymbol>();
+      ISymbolicExpressionTreeNode parent;
+      int childIndex;
+      ISymbolicExpressionTreeNode child;
+      // repeat until a fitting parent and child are found (MAX_TRIES times)
+      int tries = 0;
+      do {
+        parent = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).SelectRandom(random);
+        childIndex = random.Next(parent.SubtreeCount);
 
-      var weights = selectedManipulationPoint.AllowedSymbols.Select(s => s.InitialFrequency).ToList();
-      var newSymbol = selectedManipulationPoint.AllowedSymbols.SelectRandom(weights, random);
+        child = parent.GetSubtree(childIndex);
+        int existingSubtreeCount = child.SubtreeCount;
+        allowedSymbols.Clear();
+        foreach (var symbol in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, childIndex)) {
+          // check basic properties that the new symbol must have
+          if (symbol.Name != child.Symbol.Name &&
+            symbol.InitialFrequency > 0 &&
+            existingSubtreeCount <= parent.Grammar.GetMinimumSubtreeCount(symbol) &&
+            existingSubtreeCount >= parent.Grammar.GetMaximumSubtreeCount(symbol)) {
+            // check that all existing subtrees are also allowed for the new symbol
+            bool allExistingSubtreesAllowed = true;
+            for (int existingSubtreeIndex = 0; existingSubtreeIndex < existingSubtreeCount && allExistingSubtreesAllowed; existingSubtreeIndex++) {
+              var existingSubtree = child.GetSubtree(existingSubtreeIndex);
+              allExistingSubtreesAllowed &= parent.Grammar.IsAllowedChildSymbol(symbol, existingSubtree.Symbol, existingSubtreeIndex);
+            }
+            if (allExistingSubtreesAllowed) {
+              allowedSymbols.Add(symbol);
+            }
+          }
+        }
+        tries++;
+      } while (tries < MAX_TRIES && allowedSymbols.Count == 0);
 
-      // replace the old node with the new node
-      var newNode = newSymbol.CreateTreeNode();
-      if (newNode.HasLocalParameters)
-        newNode.ResetLocalParameters(random);
-      foreach (var subtree in selectedManipulationPoint.Child.Subtrees)
-        newNode.AddSubtree(subtree);
-      selectedManipulationPoint.Parent.RemoveSubtree(selectedManipulationPoint.Index);
-      selectedManipulationPoint.Parent.InsertSubtree(selectedManipulationPoint.Index, newNode);
+      if (tries < MAX_TRIES) {
+        var weights = allowedSymbols.Select(s => s.InitialFrequency).ToList();
+        var newSymbol = allowedSymbols.SelectRandom(weights, random);
+
+        // replace the old node with the new node
+        var newNode = newSymbol.CreateTreeNode();
+        if (newNode.HasLocalParameters)
+          newNode.ResetLocalParameters(random);
+        foreach (var subtree in child.Subtrees)
+          newNode.AddSubtree(subtree);
+        parent.RemoveSubtree(childIndex);
+        parent.InsertSubtree(childIndex, newNode);
+      }
     }
   }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs	(revision 9083)
@@ -37,4 +37,5 @@
   [StorableClass]
   public sealed class MultiSymbolicExpressionTreeManipulator : StochasticMultiBranch<ISymbolicExpressionTreeManipulator>,
+    ITracingSymbolicExpressionTreeOperator,
     ISymbolicExpressionTreeManipulator,
     IStochasticOperator,
@@ -43,4 +44,6 @@
     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
+    private const string SymbolicExpressionTreeNodeComparerParameterName = "SymbolicExpressionTreeNodeComparer";
+    private const string SymbolicExpressionTreeNodeComparerParameterDescription = "The comparison operator used to check if two symbolic expression tree nodes are equal or similar.";
 
     public override bool CanChangeName {
@@ -49,4 +52,10 @@
     protected override bool CreateChildOperation {
       get { return true; }
+    }
+    public ValueParameter<ISymbolicExpressionTreeNodeComparer> SymbolicExpressionTreeNodeComparerParameter {
+      get { return (ValueParameter<ISymbolicExpressionTreeNodeComparer>)Parameters[SymbolicExpressionTreeNodeComparerParameterName]; }
+    }
+    public ISymbolicExpressionTreeNodeComparer SymbolicExpressionTreeNodeComparer {
+      get { return (ISymbolicExpressionTreeNodeComparer)SymbolicExpressionTreeNodeComparerParameter.ActualValue; }
     }
 
@@ -71,4 +80,5 @@
       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
+      Parameters.Add(new ValueParameter<ISymbolicExpressionTreeNodeComparer>(SymbolicExpressionTreeNodeComparerParameterName, SymbolicExpressionTreeNodeComparerParameterDescription));
 
       List<ISymbolicExpressionTreeManipulator> list = new List<ISymbolicExpressionTreeManipulator>();
@@ -110,4 +120,9 @@
         manipulator.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
       }
+      var comparers = ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeNodeComparer>().ToList();
+      if (comparers.Count > 0)
+        foreach (var manipulator in Operators.OfType<ITracingSymbolicExpressionTreeOperator>()) {
+          manipulator.SymbolicExpressionTreeNodeComparerParameter.ActualValue = comparers.First();
+        }
     }
   }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs	(revision 9083)
@@ -57,4 +57,8 @@
 
     protected override void Manipulate(IRandom random, ISymbolicExpressionTree tree) {
+      OnePointShaker.Shake(random, tree, ShakingFactor);
+    }
+
+    public static void Shake(IRandom random, ISymbolicExpressionTree tree, double shakingFactor) {
       List<ISymbolicExpressionTreeNode> parametricNodes = new List<ISymbolicExpressionTreeNode>();
       tree.Root.ForEachNodePostfix(n => {
@@ -63,5 +67,5 @@
       if (parametricNodes.Count > 0) {
         var selectedPoint = parametricNodes.SelectRandom(random);
-        selectedPoint.ShakeLocalParameters(random, ShakingFactor);
+        selectedPoint.ShakeLocalParameters(random, shakingFactor);
       }
     }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs	(revision 9083)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs	(revision 9083)
@@ -0,0 +1,132 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
+  [StorableClass]
+  [Item("RemoveBranchManipulation", "Removes a random sub-tree of the input tree and fixes the tree by generating random subtrees if necessary..")]
+  public sealed class RemoveBranchManipulation : SymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
+    private const int MAX_TRIES = 100;
+    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
+    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
+    #region Parameter Properties
+    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
+      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
+    }
+    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
+      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
+    }
+    #endregion
+    #region Properties
+    public IntValue MaximumSymbolicExpressionTreeLength {
+      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
+    }
+    public IntValue MaximumSymbolicExpressionTreeDepth {
+      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
+    }
+    #endregion
+
+    [StorableConstructor]
+    private RemoveBranchManipulation(bool deserializing) : base(deserializing) { }
+    private RemoveBranchManipulation(RemoveBranchManipulation original, Cloner cloner) : base(original, cloner) { }
+    public RemoveBranchManipulation()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
+      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RemoveBranchManipulation(this, cloner);
+    }
+
+    protected override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
+      RemoveRandomBranch(random, symbolicExpressionTree, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
+    }
+
+    public static void RemoveRandomBranch(IRandom random, ISymbolicExpressionTree symbolicExpressionTree, int maxTreeLength, int maxTreeDepth) {
+      var allowedSymbols = new List<ISymbol>();
+      ISymbolicExpressionTreeNode parent;
+      int childIndex;
+      int maxLength;
+      int maxDepth;
+      // repeat until a fitting parent and child are found (MAX_TRIES times)
+      int tries = 0;
+
+      var nodes = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).ToList();
+      do {
+        parent = nodes.SelectRandom(random);
+        childIndex = random.Next(parent.SubtreeCount);
+        var child = parent.GetSubtree(childIndex);
+        maxLength = maxTreeLength - symbolicExpressionTree.Length + child.GetLength();
+        maxDepth = maxTreeDepth - symbolicExpressionTree.Depth + child.GetDepth();
+
+        allowedSymbols.Clear();
+        foreach (var symbol in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, childIndex)) {
+          // check basic properties that the new symbol must have
+          if (symbol.Name != child.Symbol.Name &&
+            symbol.InitialFrequency > 0 &&
+            parent.Grammar.GetMinimumExpressionDepth(symbol) + 1 <= maxDepth &&
+            parent.Grammar.GetMinimumExpressionLength(symbol) <= maxLength) {
+            allowedSymbols.Add(symbol);
+          }
+        }
+        tries++;
+      } while (tries < MAX_TRIES && allowedSymbols.Count == 0);
+
+      if (tries >= MAX_TRIES) return;
+      ReplaceWithMinimalTree(random, symbolicExpressionTree.Root, parent, childIndex);
+    }
+
+    private static void ReplaceWithMinimalTree(IRandom random, ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode parent, int childIndex) {
+      // determine possible symbols that will lead to the smallest possible tree
+      var possibleSymbols = (from s in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, childIndex)
+                             where s.InitialFrequency > 0.0
+                             group s by parent.Grammar.GetMinimumExpressionLength(s) into g
+                             orderby g.Key
+                             select g).First().ToList();
+      var weights = possibleSymbols.Select(x => x.InitialFrequency).ToList();
+      var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
+      var newTreeNode = selectedSymbol.CreateTreeNode();
+      if (newTreeNode.HasLocalParameters) newTreeNode.ResetLocalParameters(random);
+      parent.RemoveSubtree(childIndex);
+      parent.InsertSubtree(childIndex, newTreeNode);
+
+      var topLevelNode = newTreeNode as SymbolicExpressionTreeTopLevelNode;
+      if (topLevelNode != null)
+        topLevelNode.SetGrammar((ISymbolicExpressionTreeGrammar)root.Grammar.Clone());
+
+      for (int i = 0; i < newTreeNode.Grammar.GetMinimumSubtreeCount(newTreeNode.Symbol); i++) {
+        // insert a dummy sub-tree and add the pending extension to the list
+        var dummy = new SymbolicExpressionTreeNode();
+        newTreeNode.AddSubtree(dummy);
+        // replace the just inserted dummy by recursive application
+        ReplaceWithMinimalTree(random, root, newTreeNode, i);
+      }
+    }
+  }
+}
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs	(revision 9083)
@@ -26,4 +26,5 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Collections.Generic;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
@@ -31,4 +32,5 @@
   [Item("ReplaceBranchManipulation", "Selects a branch of the tree randomly and replaces it with a newly initialized branch (using PTC2).")]
   public sealed class ReplaceBranchManipulation : TracingSymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
+    private const int MAX_TRIES = 100;
     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
@@ -68,43 +70,43 @@
 
     public static void ReplaceRandomBranch(IRandom random, ISymbolicExpressionTree symbolicExpressionTree, int maxTreeLength, int maxTreeDepth) {
-      // select any node as parent (except the root node)
-      var manipulationPoints = (from parent in symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1)
-                                from subtree in parent.Subtrees
-                                let subtreeIndex = parent.IndexOfSubtree(subtree)
-                                let maxLength = maxTreeLength - symbolicExpressionTree.Length + subtree.GetLength()
-                                let maxDepth = maxTreeDepth - symbolicExpressionTree.Depth + subtree.GetDepth()
-                                // find possible symbols for the node (also considering the existing branches below it)
-                                let allowedSymbols = (from symbol in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, subtreeIndex)
-                                                      // do not replace symbol with the same symbol
-                                                      where symbol.Name != subtree.Symbol.Name
-                                                      where symbol.InitialFrequency > 0
-                                                      where parent.Grammar.GetMinimumExpressionDepth(symbol) + 1 <= maxDepth
-                                                      where parent.Grammar.GetMinimumExpressionLength(symbol) <= maxLength
-                                                      select symbol)
-                                                      .ToList()
-                                where allowedSymbols.Count > 0
-                                select new {
-                                  Parent = parent,
-                                  Child = subtree,
-                                  Index = subtreeIndex,
-                                  AllowedSymbols = allowedSymbols,
-                                  MaxLength = maxLength,
-                                  MaxDepth = maxDepth
-                                })
-                               .ToList();
+      var allowedSymbols = new List<ISymbol>();
+      ISymbolicExpressionTreeNode parent;
+      int childIndex;
+      int maxLength;
+      int maxDepth;
+      // repeat until a fitting parent and child are found (MAX_TRIES times)
+      int tries = 0;
+      do {
+        parent = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).SelectRandom(random);
+        childIndex = random.Next(parent.SubtreeCount);
+        var child = parent.GetSubtree(childIndex);
+        maxLength = maxTreeLength - symbolicExpressionTree.Length + child.GetLength();
+        maxDepth = maxTreeDepth - symbolicExpressionTree.Depth + child.GetDepth();
 
-      if (manipulationPoints.Count == 0) return;
-      var selectedManipulationPoint = manipulationPoints.SelectRandom(random);
+        allowedSymbols.Clear();
+        foreach (var symbol in parent.Grammar.GetAllowedChildSymbols(parent.Symbol, childIndex)) {
+          // check basic properties that the new symbol must have
+          if (symbol.Name != child.Symbol.Name &&
+            symbol.InitialFrequency > 0 &&
+            parent.Grammar.GetMinimumExpressionDepth(symbol) + 1 <= maxDepth &&
+            parent.Grammar.GetMinimumExpressionLength(symbol) <= maxLength) {
+            allowedSymbols.Add(symbol);
+          }
+        }
+        tries++;
+      } while (tries < MAX_TRIES && allowedSymbols.Count == 0);
 
-      var weights = selectedManipulationPoint.AllowedSymbols.Select(s => s.InitialFrequency).ToList();
-      var seedSymbol = selectedManipulationPoint.AllowedSymbols.SelectRandom(weights, random);
-      // replace the old node with the new node
-      var seedNode = seedSymbol.CreateTreeNode();
-      if (seedNode.HasLocalParameters)
-        seedNode.ResetLocalParameters(random);
+      if (tries < MAX_TRIES) {
+        var weights = allowedSymbols.Select(s => s.InitialFrequency).ToList();
+        var seedSymbol = allowedSymbols.SelectRandom(weights, random);
+        // replace the old node with the new node
+        var seedNode = seedSymbol.CreateTreeNode();
+        if (seedNode.HasLocalParameters)
+          seedNode.ResetLocalParameters(random);
 
-      selectedManipulationPoint.Parent.RemoveSubtree(selectedManipulationPoint.Index);
-      selectedManipulationPoint.Parent.InsertSubtree(selectedManipulationPoint.Index, seedNode);
-      ProbabilisticTreeCreator.PTC2(random, seedNode, selectedManipulationPoint.MaxLength, selectedManipulationPoint.MaxDepth);
+        parent.RemoveSubtree(childIndex);
+        parent.InsertSubtree(childIndex, seedNode);
+        ProbabilisticTreeCreator.PTC2(random, seedNode, maxLength, maxDepth);
+      }
     }
   }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs	(revision 9083)
@@ -25,5 +25,4 @@
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HeuristicLab.EvolutionaryTracking;
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
@@ -37,4 +36,6 @@
   public abstract class TracingSymbolicExpressionTreeManipulator : TracingSymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator {
     private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
+    [Storable]
+    private readonly Dictionary<Type, byte> manipulationTypes = new Dictionary<Type, byte>();
 
     #region Parameter Properties
@@ -52,8 +53,16 @@
     [StorableConstructor]
     protected TracingSymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { }
-    protected TracingSymbolicExpressionTreeManipulator(TracingSymbolicExpressionTreeManipulator original, Cloner cloner) : base(original, cloner) { }
+    protected TracingSymbolicExpressionTreeManipulator(TracingSymbolicExpressionTreeManipulator original, Cloner cloner)
+      : base(original, cloner) {
+      this.manipulationTypes = new Dictionary<Type, byte>(original.manipulationTypes);
+    }
     public TracingSymbolicExpressionTreeManipulator()
       : base() {
       Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
+
+      manipulationTypes.Add(typeof(FullTreeShaker), ManipulationType.FullTreeShaker);
+      manipulationTypes.Add(typeof(OnePointShaker), ManipulationType.OnePointShaker);
+      manipulationTypes.Add(typeof(ChangeNodeTypeManipulation), ManipulationType.ChangeNodeTypeManipulation);
+      manipulationTypes.Add(typeof(ReplaceBranchManipulation), ManipulationType.ReplaceBranchManipulation);
     }
 
@@ -72,45 +81,72 @@
        * - After tree is mutated, we set GlobalTraceMap[tree] = clone and GlobalFragmentMap[tree] = modified node from tree
        */
-      ISymbolicExpressionTreeNode fragment;
+      Fragment fragment = null;
       if (GlobalTraceMap.ContainsKey(tree)) {
-        var clone = (IItem)tree.Clone(); // create clone of tree
+        var clone = (IItem)tree.Clone();
+        GlobalCloneMap[clone] = GlobalCloneMap[tree];
+        GlobalCloneMap[tree] = clone;
         GlobalTraceMap[clone] = GlobalTraceMap[tree]; // clone gets parents of tree
         GlobalTraceMap[tree] = new ItemList<IItem> { clone }; // tree gets clone as parent
-        fragment = ((GenericWrapper<ISymbolicExpressionTreeNode>)GlobalFragmentMap[tree]).Content;
-        int index = tree.IterateNodesBreadth().ToList().IndexOf(fragment); // returns -1 if fragment is not present in tree
-        GlobalFragmentMap[clone] = new GenericWrapper<ISymbolicExpressionTreeNode>(index == -1 ? null : ((ISymbolicExpressionTree)clone).IterateNodesBreadth().ElementAt(index));
+        fragment = (Fragment)GlobalFragmentMap[tree];
+        int index = tree.IterateNodesBreadth().ToList().IndexOf(fragment.Root); // returns -1 if fragment is not present in tree (can happen if fragment is null)
+        GlobalFragmentMap[clone] = new Fragment(index == -1 ? null : ((ISymbolicExpressionTree)clone).IterateNodesBreadth().ElementAt(index));
       } else {
         GlobalTraceMap[tree] = new ItemList<IItem> { GlobalCloneMap[tree] };
       }
 
-      var original = GlobalCloneMap[tree];
-      var nodes0 = ((ISymbolicExpressionTree)original).IterateNodesBreadth().ToList();
+      var concreteType = this.GetType();
 
-      // perform mutation
+      if (!manipulationTypes.ContainsKey(concreteType))
+        throw new Exception(this.Name + ": Unknown manipulation type (key not found in the dictionary).");
+
+      var nodes0 = tree.IterateNodesBreadth().ToList(); // list of nodes before manipulation
       Manipulate(RandomParameter.ActualValue, tree);
+      var nodes1 = tree.IterateNodesBreadth().ToList(); // list of nodes after manipulation
+      int min = Math.Min(nodes0.Count, nodes1.Count);
 
-      var nodes1 = tree.IterateNodesBreadth().ToList();
+      switch (manipulationTypes[concreteType]) {
+        case ManipulationType.FullTreeShaker: {
+            // the FullTreeShaker changes the local parameters of all the nodes in the tree
+            // therefore, the whole tree is considered to be the fragment
+            fragment = new Fragment(tree.Root.GetSubtree(0).GetSubtree(0));
+            break;
+          }
+        case ManipulationType.OnePointShaker: {
+            var original = (ISymbolicExpressionTree)GlobalCloneMap[tree];
+            var nodesOriginal = original.IterateNodesBreadth().ToList();
+            int i = 0;
+            var comparer = SymbolicExpressionTreeNodeComparer;
+            while (i != min && comparer.Equals(nodesOriginal[i], nodes1[i])) ++i;
+            fragment = new Fragment(i == min ? null : nodes1[i], 1);
+            break;
+          }
+        case ManipulationType.ChangeNodeTypeManipulation: {
+            int i = 0;
+            while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i;
+            fragment = new Fragment(i == min ? null : nodes1[i], 1);
+            break;
+          }
+        case ManipulationType.ReplaceBranchManipulation: {
+            int i = 0;
+            while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i;
+            fragment = new Fragment(i == min ? null : nodes1[i]);
+            break;
+          }
+        default:
+          throw new Exception(Name + ": Unknown manipulaton type.");
+      }
 
-      int min = Math.Min(nodes0.Count, nodes1.Count);
-      // some tree manipulators only change local parameters while the actual node stays the same
-      // consequently, we need a stronger comparison than ReferenceEquals
-      var comp = SymbolicExpressionTreeNodeComparer;
-      if (comp == null)
-        throw new Exception(Name + ": Could not get SymbolicExpressionTreeNodeComparerParameter!");
-      var mismatches = new List<int>();
-      for (int i = 0; i != min; ++i) {
-        if (!comp.Equals(nodes0[i], nodes1[i])) {
-          mismatches.Add(i);
-        }
-      }
-      if (mismatches.Count == 0) // should never happen
-        fragment = null;
-      else
-        fragment = mismatches.Count > 1 ? nodes1[mismatches[0]].Parent : nodes1[mismatches[0]];
-      GlobalFragmentMap[tree] = new GenericWrapper<ISymbolicExpressionTreeNode>(fragment);
+      GlobalFragmentMap[tree] = fragment;
       return base.Apply();
     }
 
     protected abstract void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree);
+
+    private struct ManipulationType {
+      public const byte FullTreeShaker = 1;
+      public const byte OnePointShaker = 2;
+      public const byte ChangeNodeTypeManipulation = 3;
+      public const byte ReplaceBranchManipulation = 4;
+    }
   }
 }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs	(revision 9083)
@@ -23,5 +23,5 @@
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7997")]
+  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.3.8557")]
   [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
   [PluginDependency("HeuristicLab.Analysis", "3.3")]
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame	(revision 9083)
@@ -23,5 +23,5 @@
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7997")]
+  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.3.$WCREV$")]
   [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
   [PluginDependency("HeuristicLab.Analysis", "3.3")]
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame	(revision 9083)
@@ -45,3 +45,3 @@
 
 [assembly: AssemblyVersion("3.4.0.0")]
-[assembly: AssemblyFileVersion("3.4.2.$WCREV$")]
+[assembly: AssemblyFileVersion("3.4.3.$WCREV$")]
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs	(revision 9083)
@@ -181,5 +181,7 @@
 
     #region IStatefulItem methods
-    void IStatefulItem.InitializeState() { }
+    void IStatefulItem.InitializeState() {
+      ReadOnly = false;
+    }
     void IStatefulItem.ClearState() {
       ReadOnly = false;
@@ -242,5 +244,5 @@
         var groupSymbol = s as GroupSymbol;
         if (groupSymbol != null) RegisterGroupSymbolEvents(groupSymbol);
-        else symbol.Changed += new EventHandler(Symbol_Changed);
+        else s.Changed += new EventHandler(Symbol_Changed);
       }
     }
@@ -252,5 +254,5 @@
         var groupSymbol = s as GroupSymbol;
         if (groupSymbol != null) DeregisterGroupSymbolEvents(groupSymbol);
-        else symbol.Changed -= new EventHandler(Symbol_Changed);
+        else s.Changed -= new EventHandler(Symbol_Changed);
       }
     }
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 9083)
@@ -308,5 +308,5 @@
     }
     public virtual IEnumerable<ISymbol> AllowedSymbols {
-      get { return Symbols.Where(s => s.Enabled); }
+      get { foreach (var s in Symbols) if (s.Enabled) yield return s; }
     }
     public virtual bool ContainsSymbol(ISymbol symbol) {
@@ -316,17 +316,20 @@
     private readonly Dictionary<Tuple<string, string>, bool> cachedIsAllowedChildSymbol;
     public virtual bool IsAllowedChildSymbol(ISymbol parent, ISymbol child) {
+      if (allowedChildSymbols.Count == 0) return false;
       if (!child.Enabled) return false;
 
       bool result;
-      if (cachedIsAllowedChildSymbol.TryGetValue(Tuple.Create(parent.Name, child.Name), out result)) return result;
+      var key = Tuple.Create(parent.Name, child.Name);
+      if (cachedIsAllowedChildSymbol.TryGetValue(key, out result)) return result;
+
       List<string> temp;
       if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) {
         //if (temp.Contains(child.Name)) return true;
-        if (temp.SelectMany(s => GetSymbol(s).Flatten()).Where(s => s.Name == child.Name).Any()) {
-          cachedIsAllowedChildSymbol.Add(Tuple.Create(parent.Name, child.Name), true);
+        if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) {
+          cachedIsAllowedChildSymbol.Add(key, true);
           return true;
         }
       }
-      cachedIsAllowedChildSymbol.Add(Tuple.Create(parent.Name, child.Name), false);
+      cachedIsAllowedChildSymbol.Add(key, false);
       return false;
     }
@@ -336,30 +339,31 @@
       if (!child.Enabled) return false;
       if (IsAllowedChildSymbol(parent, child)) return true;
+      if (allowedChildSymbolsPerIndex.Count == 0) return false;
 
       bool result;
-      if (cachedIsAllowedChildSymbolIndex.TryGetValue(Tuple.Create(parent.Name, child.Name, argumentIndex), out result)) return result;
+      var key = Tuple.Create(parent.Name, child.Name, argumentIndex);
+      if (cachedIsAllowedChildSymbolIndex.TryGetValue(key, out result)) return result;
+
       List<string> temp;
-      var key = Tuple.Create(parent.Name, argumentIndex);
-      if (allowedChildSymbolsPerIndex.TryGetValue(key, out temp)) {
-        //if (temp.Contains(child.Name)) return true;
-        if (temp.SelectMany(s => GetSymbol(s).Flatten()).Where(s => s.Name == child.Name).Any()) {
-          cachedIsAllowedChildSymbolIndex.Add(Tuple.Create(parent.Name, child.Name, argumentIndex), true);
+      if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) {
+        if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) {
+          cachedIsAllowedChildSymbolIndex.Add(key, true);
           return true;
         }
       }
-      cachedIsAllowedChildSymbolIndex.Add(Tuple.Create(parent.Name, child.Name, argumentIndex), false);
+      cachedIsAllowedChildSymbolIndex.Add(key, false);
       return false;
     }
 
     public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) {
-      return from child in AllowedSymbols
-             where IsAllowedChildSymbol(parent, child)
-             select child;
+      foreach (ISymbol child in AllowedSymbols) {
+        if (IsAllowedChildSymbol(parent, child)) yield return child;
+      }
     }
 
     public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent, int argumentIndex) {
-      return from child in AllowedSymbols
-             where IsAllowedChildSymbol(parent, child, argumentIndex)
-             select child;
+      foreach (ISymbol child in AllowedSymbols) {
+        if (IsAllowedChildSymbol(parent, child, argumentIndex)) yield return child;
+      }
     }
 
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs	(revision 9083)
@@ -23,4 +23,5 @@
 using System.Collections.Generic;
 using System.Drawing;
+using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -75,18 +76,19 @@
     }
 
+    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
+      if (root == null)
+        return Enumerable.Empty<SymbolicExpressionTreeNode>();
+      return root.IterateNodesBreadth();
+    }
+
     public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() {
       if (root == null)
-        return new SymbolicExpressionTreeNode[0];
+        return Enumerable.Empty<SymbolicExpressionTreeNode>();
       return root.IterateNodesPrefix();
     }
     public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix() {
       if (root == null)
-        return new SymbolicExpressionTreeNode[0];
+        return Enumerable.Empty<SymbolicExpressionTreeNode>();
       return root.IterateNodesPostfix();
-    }
-    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
-      if (root == null)
-        return new SymbolicExpressionTreeNode[0];
-      return root.IterateNodesBreadth();
     }
 
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs	(revision 9083)
@@ -22,5 +22,4 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
@@ -51,5 +50,8 @@
 
     public override IEnumerable<ISymbol> Symbols {
-      get { return grammar.Symbols.Union(base.Symbols); }
+      get {
+        foreach (var s in grammar.Symbols) yield return s;
+        foreach (var s in base.symbols.Values) yield return s;
+      }
     }
     public override IEnumerable<ISymbol> AllowedSymbols {
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs	(revision 9083)
@@ -53,6 +53,8 @@
     protected SymbolicExpressionTreeNode(bool deserializing) { }
     protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original, Cloner cloner)
-      : base() {
+      : base(original, cloner) {
       symbol = original.symbol; // symbols are reused
+      length = original.length;
+      depth = original.depth;
       if (original.subtrees != null) {
         subtrees = new List<ISymbolicExpressionTreeNode>(original.subtrees.Count);
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs	(revision 9083)
@@ -30,7 +30,5 @@
   public abstract class SymbolicExpressionTreeTerminalNode : SymbolicExpressionTreeNode {
     public override IEnumerable<ISymbolicExpressionTreeNode> Subtrees {
-      get {
-        return Enumerable.Empty<ISymbolicExpressionTreeNode>();
-      }
+      get { return Enumerable.Empty<ISymbolicExpressionTreeNode>(); }
     }
 
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs	(revision 9083)
@@ -44,5 +44,4 @@
     public SymbolicExpressionTreeTopLevelNode(ISymbol symbol) : base(symbol) { }
 
-
     public override IDeepCloneable Clone(Cloner cloner) {
       return new SymbolicExpressionTreeTopLevelNode(this, cloner);
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbolTreeNode.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbolTreeNode.cs	(revision 9082)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 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 HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols {
-  [StorableClass]
-  public sealed class StartSymbolTreeNode : SymbolicExpressionTreeTopLevelNode {
-    // copy constructor
-    private StartSymbolTreeNode(StartSymbolTreeNode original)
-      : base(original) {
-    }
-
-    public StartSymbolTreeNode(StartSymbol startSymbol) : base(startSymbol) { }
-
-    public override object Clone() {
-      return new StartSymbolTreeNode(this);
-    }
-  }
-}
Index: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/TracingSymbolicExpressionTreeOperator.cs
===================================================================
--- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/TracingSymbolicExpressionTreeOperator.cs	(revision 9082)
+++ branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/TracingSymbolicExpressionTreeOperator.cs	(revision 9083)
@@ -24,6 +24,6 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
 using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>;
+using GeneticExchangeMapType = HeuristicLab.Core.ItemList<HeuristicLab.Core.IItem>;
 using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>;
 
@@ -38,4 +38,5 @@
     private const string GlobalCloneMapParameterName = "GlobalCloneMap";
     private const string GlobalFragmentMapParameterName = "GlobalFragmentMap";
+    private const string GlobalGeneticExchangeMapParameterName = "GlobalGeneticExchangeMap";
 
     private const string SymbolicExpressionTreeNodeComparerParameterName = "SymbolicExpressionTreeNodeComparer";
@@ -52,8 +53,19 @@
       get { return (LookupParameter<CloneMapType>)Parameters[GlobalFragmentMapParameterName]; }
     }
+    public LookupParameter<GeneticExchangeMapType> GlobalGeneticExchangeMapParameter {
+      get { return (LookupParameter<GeneticExchangeMapType>)Parameters[GlobalGeneticExchangeMapParameterName]; }
+    }
     public ValueParameter<ISymbolicExpressionTreeNodeComparer> SymbolicExpressionTreeNodeComparerParameter {
       get { return (ValueParameter<ISymbolicExpressionTreeNodeComparer>)Parameters[SymbolicExpressionTreeNodeComparerParameterName]; }
     }
     #endregion
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (Parameters.ContainsKey("GlobalTransactionMap"))
+        Parameters.Remove("GlobalTransactionMap");
+      if (!Parameters.ContainsKey(GlobalGeneticExchangeMapParameterName))
+        Parameters.Add(new LookupParameter<GeneticExchangeMapType>(GlobalGeneticExchangeMapParameterName, "A global list of genetic exchange transactions."));
+    }
 
     #region Properties
@@ -66,4 +78,7 @@
     public CloneMapType GlobalFragmentMap {
       get { return GlobalFragmentMapParameter.ActualValue; }
+    }
+    public GeneticExchangeMapType GlobalGeneticExchangeMap {
+      get { return GlobalGeneticExchangeMapParameter.ActualValue; }
     }
     public ISymbolicExpressionTreeNodeComparer SymbolicExpressionTreeNodeComparer {
@@ -80,4 +95,5 @@
       Parameters.Add(new LookupParameter<CloneMapType>(GlobalFragmentMapParameterName, "A global map keeping track of tree fragments received via crossover."));
       Parameters.Add(new LookupParameter<TraceMapType>(GlobalTraceMapParameterName, "A global cache containing tracing info."));
+      Parameters.Add(new LookupParameter<GeneticExchangeMapType>(GlobalGeneticExchangeMapParameterName, "A global list of genetic exchange transactions."));
       Parameters.Add(new ValueParameter<ISymbolicExpressionTreeNodeComparer>(SymbolicExpressionTreeNodeComparerParameterName, SymbolicExpressionTreeNodeComparerParameterDescription));
     }
@@ -89,4 +105,5 @@
       if (GlobalTraceMap == null) gScope.Variables.Add(new Variable(GlobalTraceMapParameterName, new TraceMapType()));
       if (GlobalFragmentMap == null) gScope.Variables.Add(new Variable(GlobalFragmentMapParameterName, new CloneMapType()));
+      if (GlobalGeneticExchangeMap == null) gScope.Variables.Add(new Variable(GlobalGeneticExchangeMapParameterName, new GeneticExchangeMapType()));
     }
   }
