Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.Cli/Program.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.Cli/Program.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.Cli/Program.cs	(revision 14513)
@@ -5,86 +5,203 @@
 using HeuristicLab.Algorithms.PushGP.Generators;
 using HeuristicLab.Algorithms.PushGP.Interpreter;
-
-namespace HeuristicLab.Algorithms.PushGP.Cli
-{
-    class Program
-    {
-        static void Main(string[] args)
-        {
-            SimpleTest();
-            //Stepwise().Wait();
-            //PerformanceTestInterpreter();
-            //PerformanceTestCodeGenerator();
-
-            Console.WriteLine("\nPress any key to continue...");
-            Console.ReadKey();
-        }
-
-        static void SimpleTest()
-        {
-            var interpreter = new PushGPInterpreter();
-
-            interpreter.Interpret("5 INTEGER.DUP INTEGER.+");
-
-            interpreter.PrintStacks();
-        }
-
-        static async Task Stepwise()
-        {
-            var interpreter = new PushGPInterpreter();
-
-            interpreter.InterpretAsync("( 0 2 CODE.QUOTE ( 1 INTEGER.+ 0 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*RANGE INTEGER.+ ) CODE.DO*RANGE )", true).Wait();
-
-            while (!interpreter.IsCompleted)
-            {
-                Console.Clear();
-                interpreter.PrintStacks();
-                interpreter.Step();
-
-                var input = Console.ReadKey();
-                if (input.Key == ConsoleKey.Escape)
-                {
-                    break;
-                }
-                else if (input.Key == ConsoleKey.Spacebar)
-                {
-                    await interpreter.ResumeAsync();
-                }
-            }
-
-            Console.Clear();
-            interpreter.PrintStacks();
-        }
-
-        static void PerformanceTestInterpreter()
-        {
-            var program = PushGPInterpreter.Encode("( 5 INTEGER.DUP INTEGER.+ )");
-            var interpreter = new PushGPInterpreter();
-            var sw = new Stopwatch();
-
-            sw.Start();
-            for (var i = 0; i < 20000000; i++)
-            {
-                interpreter.Interpret(program);
-                interpreter.Clear();
-            }
-            sw.Stop();
-
-            Console.WriteLine(sw.Elapsed);
-        }
-
-        static void PerformanceTestCodeGenerator()
-        {
-            var sw = new Stopwatch();
-
-            var interpreter = new PushGPInterpreter();
-            var generator = new CodeGenerator(interpreter);
-
-            sw.Start();
-            var expressions = generator.RandomCode(3000000);
-            sw.Stop();
-
-            Console.WriteLine(string.Format("Generated {0} in {1}", expressions.Count(), sw.Elapsed));
-        }
-    }
+using HeuristicLab.Algorithms.PushGP.Parser;
+
+namespace HeuristicLab.Algorithms.PushGP.Cli {
+
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Simplifier;
+
+  class Program {
+    static void Main(string[] args) {
+      //SimpleTest();
+      //Stepwise().Wait();
+      //PerformanceTestInterpreter();
+      //PerformanceParallelTestInterpreter();
+      //PerformanceTestCodeGenerator();
+      TestRobustness();
+      //TestPool();
+      //TestPoolPerformance();
+      //TestSimplifier();
+
+      Console.WriteLine("\nPress any key to continue...");
+      Console.ReadKey();
+    }
+
+    static void SimpleTest() {
+      var interpreter = new PushGpInterpreter();
+
+      interpreter.Interpret("5 INTEGER.DUP INTEGER.+");
+
+      interpreter.PrintStacks();
+    }
+
+    static async Task Stepwise() {
+      var interpreter = new PushGpInterpreter();
+
+      interpreter.InterpretAsync("( 0 2 CODE.QUOTE ( 1 INTEGER.+ 0 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*RANGE INTEGER.+ ) CODE.DO*RANGE )", true).Wait();
+
+      while (!interpreter.IsCompleted) {
+        Console.Clear();
+        interpreter.PrintStacks();
+        interpreter.Step();
+
+        var input = Console.ReadKey();
+        if (input.Key == ConsoleKey.Escape) {
+          break;
+        } else if (input.Key == ConsoleKey.Spacebar) {
+          await interpreter.ResumeAsync();
+        }
+      }
+
+      Console.Clear();
+      interpreter.PrintStacks();
+    }
+
+    static void PerformanceTestInterpreter() {
+      var program = PushGPParser.Parse("( 5 INTEGER.DUP INTEGER.+ )");
+
+      var interpreter = new PushGpInterpreter();
+      var sw = new Stopwatch();
+
+      sw.Start();
+      for (var i = 0; i < 60000000; i++) {
+        interpreter.Interpret(program);
+        interpreter.Clear();
+      }
+      sw.Stop();
+
+      Console.WriteLine(sw.Elapsed);
+    }
+
+    static void PerformanceParallelTestInterpreter() {
+      var program = PushGPParser.Parse("( 5 INTEGER.DUP INTEGER.+ )");
+      //var program = new ExecExpandExpression(new Expression[]
+      //{
+      //  new IntegerPushExpression(5),
+      //  new IntegerDuplicateExpression(),
+      //  new IntegerAddExpression()
+      //});
+
+      var sw = new Stopwatch();
+      var iterations = 100;
+      var amount = 600000;
+      var pool = new PushGpInterpreterPool(iterations);
+
+      sw.Start();
+      Parallel.For(0, iterations, i => {
+        using (var interpreter = pool.GetInstance()) {
+
+          for (var j = 0; j < amount; j++) {
+            interpreter.Interpret(program);
+            interpreter.Clear();
+          }
+        }
+      });
+      sw.Stop();
+
+      Console.WriteLine(sw.Elapsed);
+    }
+
+    static void PerformanceTestCodeGenerator() {
+      var sw = new Stopwatch();
+
+      sw.Start();
+      var expressions = CodeGenerator.RandomCode(3000000);
+      sw.Stop();
+
+      Console.WriteLine(string.Format("Generated {0} in {1}", expressions.Count(), sw.Elapsed));
+    }
+
+    static void TestRobustness() {
+      var sw = new Stopwatch();
+      var parallism = Environment.ProcessorCount;
+      var maxProgramSizeLimit = 100;
+      var partitionSize = 100000;
+      RandomFactory.Seed = 1337;
+
+      var execCounters = new int[parallism];
+      var config = new Configuration { EvalPushLimit = 500 };
+      var pool = new PushGpInterpreterPool(config);
+
+      sw.Start();
+      Parallel.For(0, parallism, i => {
+        using (var interpreter = pool.GetInstance()) {
+          for (var j = 0; j < partitionSize; j++) {
+            var program = CodeGenerator.RandomProgram(maxProgramSizeLimit);
+
+            interpreter.Interpret(program);
+
+            execCounters[i] += interpreter.ExecCounter;
+            interpreter.Clear();
+          }
+        }
+      });
+      sw.Stop();
+
+      Console.WriteLine("ExecCount: {0}", execCounters.Sum());
+      Console.WriteLine("Duration: {0}", sw.Elapsed);
+    }
+
+    static void TestPool() {
+      var pool = new PushGpInterpreterPool();
+      var normal = new PushGpInterpreter();
+      int id;
+
+      using (var interpreter = pool.GetInstance()) {
+        interpreter.Interpret("( 1 2 INTEGER.+ )");
+
+        id = interpreter.GetHashCode();
+        if (id == normal.GetHashCode()) Console.WriteLine("equal 1");
+      }
+
+      using (var interpreter = pool.GetInstance())
+      using (var interpreter2 = pool.GetInstance()) {
+        interpreter.Interpret("( 1 2 INTEGER.+ )");
+        if (id == interpreter.GetHashCode()) Console.WriteLine("equal 2");
+        if (id == interpreter2.GetHashCode()) Console.WriteLine("equal 3");
+      }
+    }
+
+    static void TestPoolPerformance() {
+      var sw = new Stopwatch();
+      var iterations = 100000000;
+
+      sw.Start();
+      for (var i = 0; i < iterations; i++) {
+        var interpreter = new PushGpInterpreter();
+        interpreter.Clear();
+      }
+      sw.Stop();
+
+      Console.WriteLine(sw.Elapsed);
+
+      var pool = new PushGpInterpreterPool();
+      sw.Restart();
+      for (var i = 0; i < iterations; i++) {
+        using (var interpreter = pool.GetInstance()) {
+          interpreter.Clear();
+        }
+      }
+      sw.Stop();
+
+      Console.WriteLine(sw.Elapsed);
+    }
+
+    static void TestSimplifier() {
+      var interpreter = new PushGpInterpreter();
+      var program = PushGPParser.Parse("( 5 INTEGER.DUP FLOAT.+ INTEGER.+ )") as ExecExpandExpression;
+      var simplifier = new RandomSimplifier() { Trys = 10 };
+
+      var simplerProgram = simplifier.Simplify(
+        program,
+        solution => {
+          interpreter.Clear();
+          interpreter.Interpret(solution);
+          return interpreter.IntegerStack.Top == 10;
+        });
+
+      Console.WriteLine(simplerProgram);
+    }
+  }
 }
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/ExpressionNode.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/ExpressionNode.cs	(revision 14512)
+++ 	(revision )
@@ -1,12 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HeuristicLab.Algorithms.PushGP.Data
-{
-    public class ExpressionNode
-    {
-    }
-}
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/ExpressionTree.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/ExpressionTree.cs	(revision 14512)
+++ 	(revision )
@@ -1,7 +1,0 @@
-﻿namespace HeuristicLab.Algorithms.PushGP.Data
-{
-    public class ExpressionTree
-    {
-        public ExpressionNode Root { get; set; }
-    }
-}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/IRecyclable.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/IRecyclable.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/IRecyclable.cs	(revision 14513)
@@ -0,0 +1,5 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Data.Pool {
+  public interface IRecyclable {
+    void Recycle();
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/ObjectPool.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/ObjectPool.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Pool/ObjectPool.cs	(revision 14513)
@@ -0,0 +1,106 @@
+﻿// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace HeuristicLab.Algorithms.PushGP.Data.Pool {
+  using System.Threading;
+
+  /// <summary>
+  /// Generic implementation of object pooling pattern with predefined pool size limit. The main
+  /// purpose is that limited number of frequently used objects can be kept in the pool for
+  /// further recycling.
+  ///
+  /// Notes:
+  /// 1) it is not the goal to keep all returned objects. Pool is not meant for storage. If there
+  ///    is no space in the pool, extra returned objects will be dropped.
+  ///
+  /// 2) it is implied that if object was obtained from a pool, the caller will return it back in
+  ///    a relatively short time. Keeping checked out objects for long durations is ok, but
+  ///    reduces usefulness of pooling. Just new up your own.
+  ///
+  /// Not returning objects to the pool in not detrimental to the pool's work, but is a bad practice.
+  /// Rationale:
+  ///    If there is no intent for reusing the object, do not use pool - just use "new".
+  /// </summary>
+  internal sealed class ObjectPool<T> where T : class, IRecyclable {
+    private struct Element {
+      internal T Value;
+    }
+
+    // storage for the pool objects.
+    private readonly Element[] _items;
+
+    // factory is stored for the lifetime of the pool. We will call this only when pool needs to
+    // expand. compared to "new T()", Func gives more flexibility to implementers and faster
+    // than "new T()".
+    private readonly Func<T> _factory;
+
+
+    internal ObjectPool(Func<T> factory)
+        : this(factory, Environment.ProcessorCount * 2) { }
+
+    internal ObjectPool(Func<T> factory, int size) {
+      _factory = factory;
+      _items = new Element[size];
+    }
+
+    private T CreateInstance() {
+      var inst = _factory();
+      return inst;
+    }
+
+    /// <summary>
+    /// Produces an instance.
+    /// </summary>
+    /// <remarks>
+    /// Search strategy is a simple linear probing which is chosen for it cache-friendliness.
+    /// Note that Free will try to store recycled objects close to the start thus statistically
+    /// reducing how far we will typically search.
+    /// </remarks>
+    internal T Allocate() {
+      var items = _items;
+      T inst;
+
+      for (int i = 0; i < items.Length; i++) {
+        // Note that the read is optimistically not synchronized. That is intentional.
+        // We will interlock only when we have a candidate. in a worst case we may miss some
+        // recently returned objects. Not a big deal.
+        inst = items[i].Value;
+        if (inst != null) {
+          if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst)) {
+            inst.Recycle();
+            goto gotInstance;
+          }
+        }
+      }
+
+      inst = CreateInstance();
+      gotInstance:
+
+      return inst;
+    }
+
+    /// <summary>
+    /// Returns objects to the pool.
+    /// </summary>
+    /// <remarks>
+    /// Search strategy is a simple linear probing which is chosen for it cache-friendliness.
+    /// Note that Free will try to store recycled objects close to the start thus statistically
+    /// reducing how far we will typically search in Allocate.
+    /// </remarks>
+    internal void Free(T obj) {
+      var items = _items;
+      for (int i = 0; i < items.Length; i++) {
+        if (items[i].Value == null) {
+          // Intentionally not using interlocked here.
+          // In a worst case scenario two objects may be stored into same slot.
+          // It is very unlikely to happen and will only mean that one of the objects will get collected.
+          items[i].Value = obj;
+          break;
+        }
+      }
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Random/RandomFactory.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Random/RandomFactory.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Random/RandomFactory.cs	(revision 14513)
@@ -0,0 +1,21 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Data.Random {
+  using System;
+  using System.Threading;
+
+  using HeuristicLab.Core;
+  using HeuristicLab.Random;
+
+  public class RandomFactory {
+    public static readonly RandomFactory Instance = new RandomFactory();
+
+    static RandomFactory() {
+      Seed = Environment.TickCount;
+    }
+
+    public static int Seed;
+
+    public static ThreadLocal<IRandom> GetRandom() {
+      return new ThreadLocal<IRandom>(() => new FastRandom(Seed/*Interlocked.Increment(ref Seed)*/));
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionNode.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionNode.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionNode.cs	(revision 14513)
@@ -0,0 +1,22 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Data {
+  using System.Collections.Generic;
+
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+
+  public class ExpressionNode {
+    public ExpressionNode(Expression expression) {
+      this.Expression = expression;
+    }
+
+    public Expression Expression { get; set; }
+    public IList<ExpressionNode> Children { get; set; }
+
+    public static ExpressionNode CreateNode(Expression expression) {
+      var node = new ExpressionNode(expression);
+
+
+
+      return node;
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionTree.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionTree.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Data/Tree/ExpressionTree.cs	(revision 14513)
@@ -0,0 +1,18 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Data {
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+
+  public class ExpressionTree {
+    public ExpressionNode Root { get; set; }
+
+    public static ExpressionTree BuildTree(ExecExpandExpression program)
+    {
+      var tree = new ExpressionTree { Root = new ExpressionNode(program) };
+
+      for (var i = program.Expressions.Count - 1; i >= 0; i--) {
+        tree.Root.Children.Add(ExpressionNode.CreateNode(program.Expressions[i]));
+      }
+
+      return tree;
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Exporter/Exporter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Exporter/Exporter.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Exporter/Exporter.cs	(revision 14513)
@@ -1,12 +1,12 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
+﻿namespace HeuristicLab.Algorithms.PushGP.Exporter
+{
+  using HeuristicLab.Algorithms.PushGP.Expressions;
 
-namespace HeuristicLab.Algorithms.PushGP.Exporter
-{
-    public static class Exporter
+  public static class Exporter
+  {
+    public static string ToString(Expression expression)
     {
-        public static string ToString(Expression expression)
-        {
-            return expression.ToString();
-        }
+      return expression.ToString();
     }
+  }
 }
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/ExpressionTable.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/ExpressionTable.cs	(revision 14512)
+++ 	(revision )
@@ -1,142 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-
-namespace HeuristicLab.Algorithms.PushGP
-{
-    public static class ExpressionTable
-    {
-        private static Dictionary<string, Expression> statelessExpressionTable;
-        private static Dictionary<string, Func<Expression>> statefullExpressionFactory;
-
-        public static int Count;
-
-        static ExpressionTable()
-        {
-            statelessExpressionTable = GetStatelessExperssionTable(e => e.StringRepresentation);
-            statefullExpressionFactory = GetStatefullExpressionFactory(e => e.StringRepresentation);
-
-            Count = statelessExpressionTable.Count + statefullExpressionFactory.Count;
-        }
-
-        private static Dictionary<string, Expression> GetStatelessExperssionTable(Func<Expression, string> keyFunc)
-        {
-            var dictionary = new Dictionary<string, Expression>();
-            var expressionTypes = GetExpressionTypes(typeof(StatelessExpression));
-
-            foreach (var type in expressionTypes)
-            {
-                var expression = Activator.CreateInstance(type) as Expression;
-                var key = keyFunc(expression);
-
-                try
-                {
-                    dictionary.Add(key, expression);
-                } catch(Exception e)
-                {
-                    Console.WriteLine(e);
-                }
-            }
-
-            return dictionary;
-        }
-
-        private static Dictionary<string, Func<Expression>> GetStatefullExpressionFactory(Func<Expression, string> keyFunc)
-        {
-            var dictionary = new Dictionary<string, Func<Expression>>();
-            var expressionTypes = GetExpressionTypes(typeof(StatefullExpression));
-
-            foreach (var type in expressionTypes)
-            {
-                // Make a NewExpression that calls the ctor
-                var newExp = System.Linq.Expressions.Expression.New(type);
-
-                // Create a lambda with the New expression as body
-                var creator = System.Linq.Expressions.Expression.Lambda<Func<Expression>>(newExp).Compile();
-
-                var expression = creator();
-                var key = keyFunc(expression);
-
-                try
-                {
-                    dictionary.Add(key, creator);
-                }
-                catch (Exception e)
-                {
-                    Console.WriteLine(e);
-                }
-            }
-
-            return dictionary;
-        }
-
-        private static IEnumerable<Type> GetExpressionTypes(Type baseType)
-        {
-            return from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
-                   from assemblyType in domainAssembly.GetTypes()
-                   where !assemblyType.IsAbstract &&
-                         assemblyType.IsSubclassOf(baseType) &&
-                         assemblyType.GetConstructor(Type.EmptyTypes) != null
-                   select assemblyType;
-        }
-
-        public static int StatelessCount { get { return statelessExpressionTable.Count; } }
-
-        public static int StatefullCount { get { return statefullExpressionFactory.Count; } }
-
-        public static Expression GetExpression(int index)
-        {
-            return index < StatelessCount
-                ? statelessExpressionTable.ElementAt(index).Value
-                : statefullExpressionFactory.ElementAt(index - StatelessCount).Value();
-        }
-
-        public static Expression GetExpression(string symbol)
-        {
-            Expression expression;
-            if (TryGetStatelessExpression(symbol, out expression) ||
-                TryGetStatefullExpression(symbol, out expression))
-            {
-                return expression;
-            }
-
-            return null;
-        }
-
-        public static Expression GetStatelessExpression(string symbol)
-        {
-            Expression expression;
-            if (statelessExpressionTable.TryGetValue(symbol, out expression)) return expression;
-            else throw new NotSupportedException("Expression not supported: " + symbol);
-        }
-
-        public static bool TryGetStatelessExpression(string name, out Expression expression)
-        {
-            return statelessExpressionTable.TryGetValue(name, out expression);
-        }
-
-        public static Expression GetStatefullExpression(string symbol)
-        {
-            Func<Expression> creator;
-            if (statefullExpressionFactory.TryGetValue(symbol, out creator)) return creator();
-            else throw new NotSupportedException("Expression not supported: " + symbol);
-        }
-
-        public static bool TryGetStatefullExpression(string name, out Expression expression)
-        {
-            Func<Expression> creator;
-            if (statefullExpressionFactory.TryGetValue(name, out creator))
-            {
-                expression = creator();
-                return true;
-            }
-            else
-            {
-                expression = default(Expression);
-                return false;
-            }
-
-        }
-    }
-}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/BooleanExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/BooleanExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/BooleanExpressions.cs	(revision 14513)
@@ -1,85 +1,76 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes the logical AND of the top two BOOLEANs.
-    /// </summary>
-    public class BooleanAndExpression : PushResultExpression<bool>
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "BOOLEAN.AND";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, 2, values => values[0] && values[1]);
-        }
+  /// <summary>
+  ///     Pushes the logical AND of the top two BOOLEANs.
+  /// </summary>
+  public class BooleanAndExpression : PushResultExpression<bool> {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.AND";
     }
 
-    /// <summary>
-    /// Pushes the logical OR of the top two BOOLEANs.
-    /// </summary>
-    public class BooleanOrExpression : PushResultExpression<bool>
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "BOOLEAN.OR";
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack, 2, values => values[0] && values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, 2, values => values[0] || values[1]);
-        }
+  /// <summary>
+  ///     Pushes the logical OR of the top two BOOLEANs.
+  /// </summary>
+  public class BooleanOrExpression : PushResultExpression<bool> {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.OR";
     }
 
-    /// <summary>
-    /// Pushes the logical NOT of the top BOOLEAN.
-    /// </summary>
-    public class BooleanNotExpression : PushResultExpression<bool>
-    {
-        protected override string InitStringRepresentation() { return "BOOLEAN.NOT"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack, 2, values => values[0] || values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, 1, values => !values[0]);
-        }
+  /// <summary>
+  ///     Pushes the logical NOT of the top BOOLEAN.
+  /// </summary>
+  public class BooleanNotExpression : PushResultExpression<bool> {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.NOT";
     }
 
-    /// <summary>
-    /// Pushes FALSE if the top FLOAT is 0.0, or TRUE otherwise.
-    /// </summary>
-    public class BooleanFromFloatExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "BOOLEAN.FROMFLOAT"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack, 1, values => !values[0]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.FloatStack.Count == 0)
-                return;
-
-            var value = interpreter.FloatStack.Pop() != 0.0;
-
-            interpreter.BooleanStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes FALSE if the top FLOAT is 0.0, or TRUE otherwise.
+  /// </summary>
+  public class BooleanFromFloatExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.FROMFLOAT";
     }
 
-    /// <summary>
-    /// Pushes FALSE if the top INTEGER is 0, or TRUE otherwise.
-    /// </summary>
-    public class BooleanFromIntegerExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "BOOLEAN.FROMINTEGER"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.FloatStack.Count == 0) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0)
-                return;
+      var value = interpreter.FloatStack.Pop() != 0.0;
 
-            var value = interpreter.IntegerStack.Pop() != 0;
+      interpreter.BooleanStack.Push(value);
+    }
+  }
 
-            interpreter.BooleanStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes FALSE if the top INTEGER is 0, or TRUE otherwise.
+  /// </summary>
+  public class BooleanFromIntegerExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.FROMINTEGER";
     }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.IntegerStack.Count == 0) return;
+
+      var value = interpreter.IntegerStack.Pop() != 0;
+
+      interpreter.BooleanStack.Push(value);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/CodeExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/CodeExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/CodeExpressions.cs	(revision 14513)
@@ -1,8 +1,3 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-
-/// <summary>
+﻿/// <summary>
 /// For explicit code manipulation and execution. May also be used as a general list data type.
 /// This type must always be present, as the top level interpreter will push any code to be executed on the
@@ -10,932 +5,802 @@
 /// </summary>
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Recursively invokes the interpreter on the program on top of the CODE stack. After evaluation the
-    /// CODE stack is popped; normally this pops the program that was just executed, but if the expression itself
-    /// manipulates the stack then this final pop may end up popping something else.
-    /// </summary>
-    public class CodeDoExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DO";
+namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using System;
+  using System.Collections.Generic;
+  using System.Linq;
+
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  /// <summary>
+  ///     Recursively invokes the interpreter on the program on top of the CODE stack. After evaluation the
+  ///     CODE stack is popped; normally this pops the program that was just executed, but if the expression itself
+  ///     manipulates the stack then this final pop may end up popping something else.
+  /// </summary>
+  public class CodeDoExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DO";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if (interpreter.CodeStack.Count == 0) return;
+
+      interpreter.ExecStack.Push(new CodePopExpression(), interpreter.CodeStack.Top);
+    }
+  }
+
+  /// <summary>
+  ///     Like CODE.DO but pops the stack before, rather than after, the recursive execution
+  /// </summary>
+  public class CodeDoXExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DO*";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if (interpreter.CodeStack.Count == 0) return;
+
+      var expression = interpreter.CodeStack.Pop();
+      interpreter.ExecStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Does nothing.
+  /// </summary>
+  public class CodeNoopExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.NOOP";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // nothing to do
+    }
+  }
+
+  /// <summary>
+  ///     Specifies that the next expression submitted for execution will instead be pushed literally onto the CODE stack.
+  ///     This can be implemented by moving the top item on the EXEC stack onto the CODE stack.
+  /// </summary>
+  public class CodeQuoteExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.QUOTE";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if (interpreter.ExecStack.Count == 0) return;
+
+      var expression = interpreter.ExecStack.Pop();
+      interpreter.CodeStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     If the top item of the BOOLEAN stack is TRUE this recursively executes the second item of the CODE stack;
+  ///     otherwise it recursively executes the first item of the CODE stack. Either way both elements of the CODE stack
+  ///     (and the BOOLEAN value upon which the decision was made) are popped.
+  /// </summary>
+  public class CodeIfExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.IF";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if ((interpreter.BooleanStack.Count == 0) || (interpreter.CodeStack.Count < 2)) return;
+
+      var condition = interpreter.BooleanStack.Pop();
+      var items = interpreter.CodeStack.Pop(2);
+
+      interpreter.ExecStack.Push(condition ? items[0] : items[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the result of appending the top two pieces of code. If one of the pieces of code is a single instruction or
+  ///     literal (that is, something not surrounded by parentheses) then it is surrounded by parentheses first.
+  /// </summary>
+  public class CodeAppendExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.APPEND";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count < 2) return;
+
+      var first = interpreter.CodeStack.Pop();
+      var second = interpreter.CodeStack.Top;
+
+      var isFirstList = first.GetType() == typeof(ExecExpandExpression);
+      var isSecondList = second.GetType() == typeof(ExecExpandExpression);
+
+      Expression[] result = null;
+
+      if (isFirstList) {
+        var expand1 = first as ExecExpandExpression;
+
+        if (isSecondList) {
+          var expand2 = second as ExecExpandExpression;
+          var size = expand2.Expressions.Count + expand1.Expressions.Count;
+
+          // if size > maxPointsInProgram this expressions results in a NOOP
+          if (size > interpreter.Configuration.MaxPointsInProgram) return;
+
+          result = new Expression[size];
+
+          Array.Copy(expand2.Expressions as Expression[], result, expand2.Expressions.Count);
+          Array.Copy(
+            expand1.Expressions as Expression[],
+            0,
+            result,
+            expand2.Expressions.Count,
+            expand1.Expressions.Count);
+        } else {
+          var size = expand1.Expressions.Count + 1;
+
+          // if size > maxPointsInProgram this expressions results in a NOOP
+          if (size > interpreter.Configuration.MaxPointsInProgram) return;
+
+          result = new Expression[size];
+          result[0] = second;
+
+          Array.Copy(expand1.Expressions as Expression[], 0, result, 1, expand1.Expressions.Count);
         }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            interpreter.ExecStack.Push(interpreter.CodeStack.Top);
-            interpreter.CodeStack.Pop();
+      } else if (isSecondList) {
+        var expand2 = second as ExecExpandExpression;
+
+        var size = expand2.Expressions.Count + 1;
+
+        // if size > maxPointsInProgram this expressions results in a NOOP
+        if (size > interpreter.Configuration.MaxPointsInProgram) return;
+
+        result = new Expression[size];
+        result[0] = first;
+
+        Array.Copy(expand2.Expressions as Expression[], 0, result, 1, expand2.Expressions.Count);
+      } else {
+        result = new[] { second, first };
+      }
+
+      var expression = new ExecExpandExpression(result);
+
+      interpreter.CodeStack.SetTop(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the top piece of code is a single instruction or a literal,
+  ///     and FALSE otherwise (that is, if it is something surrounded by parentheses).
+  /// </summary>
+  public class CodeAtomExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.ATOM";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count == 0) return;
+
+      var expression = interpreter.CodeStack.Pop();
+      var isExpandExpression = expression.GetType() != typeof(ExecExpandExpression);
+
+      interpreter.BooleanStack.Push(isExpandExpression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the first item of the list on top of the CODE stack. For example, if the top piece of code is "( A B )"
+  ///     then this pushes "A" (after popping the argument). If the code on top of the stack is not a list then this has no
+  ///     effect.
+  ///     The name derives from the similar Lisp function; a more generic name would be "FIRST".
+  /// </summary>
+  public class CodeCarExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.CAR";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count == 0) || (interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))) return;
+
+      var expand = interpreter.CodeStack.Top as ExecExpandExpression;
+
+      if (!expand.IsEmpty) {
+        var first = expand.Expressions[expand.Expressions.Count - 1];
+
+        interpreter.CodeStack.SetTop(first);
+      }
+    }
+  }
+
+  /// <summary>
+  ///     Pushes a version of the list from the top of the CODE stack without its first element.
+  ///     For example, if the top piece of code is "( A B )" then this pushes "( B )" (after popping the argument).
+  ///     If the code on top of the stack is not a list then this pushes the empty list ("( )"). The name derives from
+  ///     the similar Lisp function; a more generic name would be "REST".
+  /// </summary>
+  public class CodeCdrExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.CDR";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count == 0) return;
+
+      Expression expandExpression = null;
+      var top = interpreter.CodeStack.Top;
+
+      if (top.GetType() == typeof(ExecExpandExpression)) {
+        var expand = top as ExecExpandExpression;
+
+        if (expand.IsEmpty) return;
+        var length = expand.Expressions.Count - 1;
+        var newExpressions = new Expression[length];
+
+        Array.Copy(expand.Expressions as Expression[], 0, newExpressions, 0, length);
+
+        expandExpression = new ExecExpandExpression(newExpressions);
+      } else {
+        expandExpression = ExecExpandExpression.Empty;
+      }
+
+      interpreter.CodeStack.SetTop(expandExpression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the result of "consing" (in the Lisp sense) the second stack item onto the first stack item
+  ///     (which is coerced to a list if necessary). For example, if the top piece of code is "( A B )" and the
+  ///     second piece of code is "X" then this pushes "( X A B )" (after popping the argument).
+  /// </summary>
+  public class CodeConsExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.CONS";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count < 2)
+          || (interpreter.CodeStack[interpreter.CodeStack.Count - 1].GetType() != typeof(ExecExpandExpression))) return;
+
+      var first = interpreter.CodeStack.Pop() as ExecExpandExpression;
+
+      var size = first.Expressions.Count + 1;
+
+      if (size > interpreter.Configuration.MaxPointsInProgram) return;
+
+      var expressions = new Expression[size];
+
+      expressions[first.Expressions.Count] = interpreter.CodeStack.Top;
+      Array.Copy(first.Expressions as Expression[], expressions, first.Expressions.Count);
+
+      var result = new ExecExpandExpression(expressions);
+      interpreter.CodeStack.SetTop(result);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the "container" of the second CODE stack item within the first CODE stack item onto the CODE stack.
+  ///     If second item contains the first anywhere (i.e. in any nested list) then the container is the smallest sub-list
+  ///     that contains but is not equal to the first instance. For example, if the top piece of code is "( B ( C ( A ) ) ( D
+  ///     ( A ) ) )"
+  ///     and the second piece of code is "( A )" then this pushes ( C ( A ) ). Pushes an empty list if there is no such
+  ///     container.
+  /// </summary>
+  public class CodeContainerExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.CONTAINER";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count < 2)
+          || (interpreter.CodeStack[interpreter.CodeStack.Count - 2].GetType() != typeof(ExecExpandExpression))) return;
+
+      var target = interpreter.CodeStack.Pop();
+      var source = interpreter.CodeStack.Top;
+
+      var container = this.GetContainer(null, source as ExecExpandExpression, target);
+      var result = container == null ? ExecExpandExpression.Empty : container;
+
+      interpreter.CodeStack.SetTop(result);
+    }
+
+    private ExecExpandExpression GetContainer(
+      ExecExpandExpression parent,
+      ExecExpandExpression current,
+      Expression target) {
+      var subContainer =
+        current.Expressions.Where(e => e.GetType() == typeof(ExecExpandExpression))
+          .Select(e => this.GetContainer(current, e as ExecExpandExpression, target))
+          .Where(e => e != null);
+
+      if (subContainer.Any()) return subContainer.OrderBy(c => c.Expressions.Count).LastOrDefault();
+      return current.Expressions.Contains(target) ? current : null;
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE on the BOOLEAN stack if the second CODE stack item contains the first CODE stack
+  ///     item anywhere (e.g. in a sub-list).
+  /// </summary>
+  public class CodeContainsExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.CONTAINS";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count < 2)
+          || (interpreter.CodeStack[interpreter.CodeStack.Count - 2].GetType() != typeof(ExecExpandExpression))) return;
+
+      var values = interpreter.CodeStack.Pop(2);
+      var second = values[0] as ExecExpandExpression;
+
+      interpreter.BooleanStack.Push(second.Expressions.Contains(values[1]));
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the definition associated with the top NAME on the NAME stack (if any) onto the CODE stack.
+  ///     This extracts the definition for inspection/manipulation, rather than for immediate execution (although it
+  ///     may then be executed with a call to CODE.DO or a similar instruction).
+  /// </summary>
+  public class CodeDefinitionExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DEFINITION";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.NameStack.Count == 0) || !interpreter.CustomExpressions.ContainsKey(interpreter.NameStack.Top)) return;
+
+      var name = interpreter.NameStack.Pop();
+      var definition = interpreter.CustomExpressions[name];
+
+      interpreter.CodeStack.Push(definition);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes a measure of the discrepancy between the top two CODE stack items onto the INTEGER stack. This will be zero
+  ///     if the top
+  ///     two items are equivalent, and will be higher the 'more different' the items are from one another. The calculation
+  ///     is as follows:
+  ///     <list type="bullet">
+  ///         <item>
+  ///             <description>
+  ///                 Construct a list of all of the unique items in both of the lists(where uniqueness is determined by
+  ///                 equalp).
+  ///                 Sub-lists and atoms all count as items.
+  ///         </item>
+  ///         <item>
+  ///             <description>Initialize the result to zero.
+  ///         </item>
+  ///         <item>
+  ///             <description>
+  ///                 For each unique item increment the result by the difference between the number of occurrences of the
+  ///                 item in
+  ///                 the two pieces of code.
+  ///         </item>
+  ///         <item>
+  ///             <description>Push the result.
+  ///         </item>
+  ///     </list>
+  /// </summary>
+  public class CodeDiscrepancyExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DISCREPANCY";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count < 2) return;
+
+      var expressions = interpreter.CodeStack.Pop(2);
+      var firstItems = new Dictionary<int, int>();
+      var secondItems = new Dictionary<int, int>();
+
+      this.DetermineUniqueItems(expressions[0], secondItems);
+      this.DetermineUniqueItems(expressions[1], firstItems);
+
+      var discrepancy = this.GetDiscrepancy(firstItems, secondItems);
+
+      interpreter.IntegerStack.Push(discrepancy);
+    }
+
+    private int GetDiscrepancy(IDictionary<int, int> first, IDictionary<int, int> second) {
+      var discrepancy = 0;
+      var keys = first.Keys.Concat(second.Keys).Distinct();
+
+      foreach (var key in keys)
+        if (first.ContainsKey(key) && second.ContainsKey(key)) discrepancy += Math.Abs(first[key] - second[key]);
+        else if (first.ContainsKey(key)) discrepancy += first[key];
+        else discrepancy += second[key];
+
+      return discrepancy;
+    }
+
+    private void DetermineUniqueItems(Expression source, IDictionary<int, int> items) {
+      if (source.GetType() == typeof(ExecExpandExpression)) {
+        var expand = source as ExecExpandExpression;
+
+        foreach (var e in expand.Expressions) {
+          var id = e.GetHashCode();
+          if (!items.ContainsKey(id)) items.Add(id, 1);
+          else items[id]++;
         }
-    }
-
-    /// <summary>
-    /// Like CODE.DO but pops the stack before, rather than after, the recursive execution
-    /// </summary>
-    public class CodeDoXExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DO*";
+      } else {
+        items.Add(source.GetHashCode(), 1);
+      }
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the sub-expression of the top item of the CODE stack that is indexed by the top item of the INTEGER stack.
+  ///     The indexing here counts "points," where each parenthesized expression and each literal/instruction is considered a
+  ///     point,
+  ///     and it proceeds in depth first order. The entire piece of code is at index 0; if it is a list then the first item
+  ///     in the list
+  ///     is at index 1, etc. The integer used as the index is taken modulo the number of points in the overall expression
+  ///     (and its
+  ///     absolute value is taken in case it is negative) to ensure that it is within the meaningful range.
+  /// </summary>
+  public class CodeExtractExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.EXTRACT";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.IntegerStack.Count == 0) || (interpreter.CodeStack.Count == 0)
+          || (interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))) return;
+
+      var expression = interpreter.CodeStack.Top as ExecExpandExpression;
+      var index = (int)Math.Abs(interpreter.IntegerStack.Pop() % expression.TotalCount);
+      var result = expression.GetFromTree(index);
+
+      interpreter.CodeStack.SetTop(result);
+    }
+  }
+
+  /// <summary>
+  ///     Pops the BOOLEAN stack and pushes the popped item (TRUE or FALSE) onto the CODE stack.
+  /// </summary>
+  public class CodeFromBooleanExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.FROMBOOLEAN";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.BooleanStack.Count == 0) return;
+
+      var value = interpreter.BooleanStack.Pop();
+      var expression = new BooleanPushExpression(value);
+
+      interpreter.CodeStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Pops the FLOAT stack and pushes the popped item onto the CODE stack.
+  /// </summary>
+  public class CodeFromFloatExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.FROMFLOAT";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.FloatStack.Count == 0) return;
+
+      var value = interpreter.FloatStack.Pop();
+      var expression = new FloatPushExpression(value);
+
+      interpreter.CodeStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Pops the INTEGER stack and pushes the popped integer onto the CODE stack.
+  /// </summary>
+  public class CodeFromIntegerExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.FROMINTEGER";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.IntegerStack.Count == 0) return;
+
+      var value = interpreter.IntegerStack.Pop();
+      var expression = new IntegerPushExpression(value);
+
+      interpreter.CodeStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Pops the NAME stack and pushes the popped item onto the CODE stack.
+  /// </summary>
+  public class CodeFromNameExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.FROMNAME";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.NameStack.Count == 0) return;
+
+      var value = interpreter.NameStack.Pop();
+      var expression = new NameDefineXExecExpression(value);
+
+      interpreter.CodeStack.Push(expression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the result of inserting the second item of the CODE stack into the first item, at the position indexed
+  ///     by the top item of the INTEGER stack (and replacing whatever was there formerly).
+  /// </summary>
+  public class CodeInsertExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.INSERT";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.IntegerStack.Count == 0) || (interpreter.CodeStack.Count < 2)
+          || (interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))) return;
+
+      var source = interpreter.CodeStack[interpreter.CodeStack.Count - 2];
+      var target = interpreter.CodeStack.Pop() as ExecExpandExpression;
+      var index = (int)interpreter.IntegerStack.Pop();
+
+      Expression[] newExpressions;
+      if (target.Expressions.Count > 0) {
+        index = target.Expressions.Count - 1 - Math.Abs(index % target.Expressions.Count);
+
+        newExpressions = target.CopyExpressions();
+        newExpressions[index] = source.GetType() == typeof(ExecExpandExpression)
+          ? (source as ExecExpandExpression).Copy()
+          : source;
+      } else {
+        newExpressions = new[] { source };
+      }
+
+      var result = new ExecExpandExpression(newExpressions);
+      interpreter.CodeStack.SetTop(result);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the length of the top item on the CODE stack onto the INTEGER stack.
+  ///     If the top item is not a list then this pushes a 1. If the top item is a list then this pushes the
+  ///     number of items in the top level of the list; that is, nested lists contribute only 1 to this count, no
+  ///     matter what they contain.
+  /// </summary>
+  public class CodeLengthExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.LENGTH";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count == 0) return;
+
+      var expression = interpreter.CodeStack.Pop();
+      var count = 1;
+
+      if (expression.GetType() == typeof(ExecExpandExpression)) count = (expression as ExecExpandExpression).Expressions.Count;
+
+      interpreter.IntegerStack.Push(count);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes a list of the top two items of the CODE stack onto the CODE stack.
+  /// </summary>
+  public class CodeListExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.LIST";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count < 2) return;
+
+      var first = interpreter.CodeStack.Pop();
+      var second = interpreter.CodeStack.Top;
+
+      var expandExpression = new ExecExpandExpression(new[] { second, first });
+
+      interpreter.CodeStack.SetTop(expandExpression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the second item of the CODE stack is a member of the first item
+  ///     (which is coerced to a list if necessary). Pushes FALSE onto the BOOLEAN stack otherwise.
+  /// </summary>
+  public class CodeMemberExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.MEMBER";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count < 2) return;
+
+      var expressions = interpreter.CodeStack.Pop(2);
+
+      var contains = expressions[1].GetType() == typeof(ExecExpandExpression)
+                       ? (expressions[1] as ExecExpandExpression).Expressions.Contains(expressions[0])
+                       : expressions[1].Equals(expressions[0]);
+
+      interpreter.BooleanStack.Push(contains);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the nth element of the expression on top of the CODE stack (which is coerced to a list first if necessary).
+  ///     If the expression is an empty list then the result is an empty list. N is taken from the INTEGER stack and is taken
+  ///     modulo the length of the expression into which it is indexing.
+  /// </summary>
+  public class CodeNthExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.NTH";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count == 0) || (interpreter.IntegerStack.Count == 0)) return;
+
+      var n = interpreter.IntegerStack.Pop();
+      var expression = interpreter.CodeStack.Top;
+
+      Expression nthExpression = null;
+
+      if (expression.GetType() == typeof(ExecExpandExpression)) {
+        var subExpression = expression as ExecExpandExpression;
+
+        if (subExpression.IsEmpty) {
+          nthExpression = ExecExpandExpression.Empty;
+        } else {
+          var index = (int)(subExpression.Expressions.Count - 1 - Math.Abs(n % subExpression.Expressions.Count));
+
+          nthExpression = subExpression.Expressions[index];
         }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            var expression = interpreter.CodeStack.Pop();
-            interpreter.ExecStack.Push(expression);
+      } else {
+        nthExpression = expression;
+      }
+
+      interpreter.CodeStack.SetTop(nthExpression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the nth "CDR" (in the Lisp sense) of the expression on top of the CODE stack (which is coerced to a list
+  ///     first if necessary). If the expression is an empty list then the result is an empty list. N is taken from the
+  ///     INTEGER
+  ///     stack and is taken modulo the length of the expression into which it is indexing. A "CDR" of a list is the list
+  ///     without
+  ///     its first element.
+  /// </summary>
+  public class CodeNthCdrExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.NTHCDR";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count == 0) || (interpreter.IntegerStack.Count == 0)) return;
+
+      var n = interpreter.IntegerStack.Pop();
+      var expression = interpreter.CodeStack.Top;
+
+      Expression nthExpression = null;
+
+      if (expression.GetType() == typeof(ExecExpandExpression)) {
+        var subExpressions = (expression as ExecExpandExpression).Expressions;
+
+        if (subExpressions.Count < 2) {
+          nthExpression = ExecExpandExpression.Empty;
+        } else {
+          var index = (int)(subExpressions.Count - 2 - Math.Abs(n % (subExpressions.Count - 1)));
+
+          nthExpression = subExpressions[index];
         }
-    }
-
-    /// <summary>
-    /// Does nothing.
-    /// </summary>
-    public class CodeNoopExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.NOOP";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // nothing to do
-        }
-    }
-
-    /// <summary>
-    /// Specifies that the next expression submitted for execution will instead be pushed literally onto the CODE stack.
-    /// This can be implemented by moving the top item on the EXEC stack onto the CODE stack.
-    /// </summary>
-    public class CodeQuoteExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.QUOTE";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.ExecStack.Count == 0)
-                return;
-
-            var expression = interpreter.ExecStack.Pop();
-            interpreter.CodeStack.Push(expression);
-        }
-    }
-
-    /// <summary>
-    /// If the top item of the BOOLEAN stack is TRUE this recursively executes the second item of the CODE stack;
-    /// otherwise it recursively executes the first item of the CODE stack. Either way both elements of the CODE stack
-    /// (and the BOOLEAN value upon which the decision was made) are popped.
-    /// </summary>
-    public class CodeIfExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.IF";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.BooleanStack.Count == 0 ||
-                interpreter.CodeStack.Count < 2)
-                return;
-
-            var condition = interpreter.BooleanStack.Pop();
-            var items = interpreter.CodeStack.Pop(2);
-
-            interpreter.ExecStack.Push(condition
-                ? items[0]
-                : items[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the result of appending the top two pieces of code. If one of the pieces of code is a single instruction or
-    /// literal (that is, something not surrounded by parentheses) then it is surrounded by parentheses first.
-    /// </summary>
-    public class CodeAppendExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.APPEND";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2)
-                return;
-
-            var first = interpreter.CodeStack.Pop();
-            var second = interpreter.CodeStack.Top;
-
-            var isFirstList = first.GetType() == typeof(ExecExpandExpression);
-            var isSecondList = second.GetType() == typeof(ExecExpandExpression);
-
-            List<Expression> result = null;
-
-            if (isFirstList)
-            {
-                var expand1 = first as ExecExpandExpression;
-
-                if (isSecondList)
-                {
-                    var expand2 = second as ExecExpandExpression;
-
-                    result = new List<Expression>(expand2.Expressions.Length + expand1.Expressions.Length);
-                    result.AddRange(expand2.Expressions);
-                    result.AddRange(expand1.Expressions);
-                }
-                else
-                {
-                    result = new List<Expression>(expand1.Expressions.Length + 1);
-                    result.Add(second);
-                    result.AddRange(expand1.Expressions);
-                }
-            }
-            else if (isSecondList)
-            {
-                var expand2 = second as ExecExpandExpression;
-
-                result = new List<Expression>(expand2.Expressions.Length + 1);
-                result.Add(first);
-                result.AddRange(expand2.Expressions);
-            }
-            else
-            {
-                result = new List<Expression> { second, first };
-            }
-
-            interpreter.CodeStack.SetTop(ExecExpandExpression.TryCreate(result.ToArray(), interpreter.Configuration));
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the top piece of code is a single instruction or a literal,
-    /// and FALSE otherwise (that is, if it is something surrounded by parentheses).
-    /// </summary>
-    public class CodeAtomExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.ATOM";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            var expression = interpreter.CodeStack.Pop();
-            var isExpandExpression = expression.GetType() != typeof(ExecExpandExpression);
-
-            interpreter.BooleanStack.Push(isExpandExpression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the first item of the list on top of the CODE stack. For example, if the top piece of code is "( A B )"
-    /// then this pushes "A" (after popping the argument). If the code on top of the stack is not a list then this has no effect.
-    /// The name derives from the similar Lisp function; a more generic name would be "FIRST".
-    /// </summary>
-    public class CodeCarExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.CAR";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0 ||
-                interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))
-                return;
-
-            var expression = interpreter.CodeStack.Pop() as ExecExpandExpression;
-            if (expression.Expressions.Length > 0)
-            {
-                var first = expression.Expressions[expression.Expressions.Length - 1];
-
-                interpreter.CodeStack.Push(first);
-            }
-
-        }
-    }
-
-    /// <summary>
-    /// Pushes a version of the list from the top of the CODE stack without its first element.
-    /// For example, if the top piece of code is "( A B )" then this pushes "( B )" (after popping the argument).
-    /// If the code on top of the stack is not a list then this pushes the empty list ("( )"). The name derives from
-    /// the similar Lisp function; a more generic name would be "REST".
-    /// </summary>
-    public class CodeCdrExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.CDR";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            Expression expandExpression = null;
-            var top = interpreter.CodeStack.Top;
-
-            if (top.GetType() == typeof(ExecExpandExpression))
-            {
-                var expand = top as ExecExpandExpression;
-
-                if (expand.IsEmpty)
-                {
-                    return;
-                }
-                else
-                {
-                    var length = expand.Expressions.Length - 1;
-                    var newExpressions = new Expression[length];
-
-                    Array.Copy(expand.Expressions, 0, newExpressions, 0, length);
-
-                    expandExpression = new ExecExpandExpression(newExpressions);
-                }
-            }
-            else
-            {
-                expandExpression = ExecExpandExpression.Empty;
-            }
-
-            interpreter.CodeStack.SetTop(expandExpression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the result of "consing" (in the Lisp sense) the second stack item onto the first stack item
-    /// (which is coerced to a list if necessary). For example, if the top piece of code is "( A B )" and the
-    /// second piece of code is "X" then this pushes "( X A B )" (after popping the argument).
-    /// </summary>
-    public class CodeConsExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.CONS";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2 ||
-                interpreter.CodeStack[interpreter.CodeStack.Count - 1].GetType() != typeof(ExecExpandExpression))
-                return;
-
-            var first = interpreter.CodeStack.Pop() as ExecExpandExpression;
-            var expressions = new Expression[first.Expressions.Length + 1];
-
-            expressions[first.Expressions.Length] = interpreter.CodeStack.Top;
-            Array.Copy(first.Expressions, 0, expressions, 0, first.Expressions.Length);
-
-            interpreter.CodeStack.SetTop(ExecExpandExpression.TryCreate(expressions, interpreter.Configuration));
-        }
-    }
-
-    /// <summary>
-    /// Pushes the "container" of the second CODE stack item within the first CODE stack item onto the CODE stack.
-    /// If second item contains the first anywhere (i.e. in any nested list) then the container is the smallest sub-list
-    /// that contains but is not equal to the first instance. For example, if the top piece of code is "( B ( C ( A ) ) ( D ( A ) ) )"
-    /// and the second piece of code is "( A )" then this pushes ( C ( A ) ). Pushes an empty list if there is no such container.
-    /// </summary>
-    public class CodeContainerExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.CONTAINER";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2 ||
-                interpreter.CodeStack[interpreter.CodeStack.Count - 2].GetType() != typeof(ExecExpandExpression))
-            {
-                return;
-            }
-
-            var target = interpreter.CodeStack.Pop();
-            var source = interpreter.CodeStack.Top;
-
-            var container = GetContainer(null, source as ExecExpandExpression, target);
-            var result = container == null
-                ? ExecExpandExpression.Empty
-                : container;
-
-            interpreter.CodeStack.SetTop(result);
-        }
-
-        private ExecExpandExpression GetContainer(ExecExpandExpression parent, ExecExpandExpression current, Expression target)
-        {
-            var subContainer = current.Expressions
-                    .Where(e => e.GetType() == typeof(ExecExpandExpression))
-                    .Select(e => GetContainer(current, e as ExecExpandExpression, target))
-                    .Where(e => e != null);
-
-            if (subContainer.Any())
-            {
-                return subContainer.OrderBy(c => c.Expressions.Length).LastOrDefault();
-            }
-            else return current.Expressions.Contains(target)
-                ? current
-                : null;
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE on the BOOLEAN stack if the second CODE stack item contains the first CODE stack
-    /// item anywhere (e.g. in a sub-list).
-    /// </summary>
-    public class CodeContainsExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.CONTAINS";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2 ||
-                interpreter.CodeStack[interpreter.CodeStack.Count - 2].GetType() != typeof(ExecExpandExpression))
-                return;
-
-            var values = interpreter.CodeStack.Pop(2);
-            var second = values[0] as ExecExpandExpression;
-
-            interpreter.BooleanStack.Push(second.Expressions.Contains(values[1]));
-        }
-    }
-
-    /// <summary>
-    /// Pushes the definition associated with the top NAME on the NAME stack (if any) onto the CODE stack.
-    /// This extracts the definition for inspection/manipulation, rather than for immediate execution (although it
-    /// may then be executed with a call to CODE.DO or a similar instruction).
-    /// </summary>
-    public class CodeDefinitionExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DEFINITION";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.NameStack.Count == 0 ||
-                !interpreter.CustomExpressions.ContainsKey(interpreter.NameStack.Top))
-                return;
-
-            var name = interpreter.NameStack.Pop();
-            var definition = interpreter.CustomExpressions[name];
-
-            interpreter.CodeStack.Push(definition);
-        }
-    }
-
-    /// <summary>
-    /// Pushes a measure of the discrepancy between the top two CODE stack items onto the INTEGER stack. This will be zero if the top
-    /// two items are equivalent, and will be higher the 'more different' the items are from one another. The calculation is as follows:
-    /// <list type="bullet">
-    /// <item><description>Construct a list of all of the unique items in both of the lists(where uniqueness is determined by equalp).
-    /// Sub-lists and atoms all count as items.
-    /// </item>
-    /// <item><description>Initialize the result to zero.
-    /// </item>
-    /// <item><description>For each unique item increment the result by the difference between the number of occurrences of the item in
-    /// the two pieces of code.
-    /// </item>
-    /// <item><description>Push the result.
-    /// </item>
-    /// </list>
-    /// </summary>
-    public class CodeDiscrepancyExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DISCREPANCY";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2)
-                return;
-
-            var expressions = interpreter.CodeStack.Pop(2);
-            var firstItems = new Dictionary<int, int>();
-            var secondItems = new Dictionary<int, int>();
-
-            DetermineUniqueItems(expressions[0], secondItems);
-            DetermineUniqueItems(expressions[1], firstItems);
-
-            var discrepancy = GetDiscrepancy(firstItems, secondItems);
-
-            interpreter.IntegerStack.Push(discrepancy);
-        }
-
-        private int GetDiscrepancy(IDictionary<int, int> first, IDictionary<int, int> second)
-        {
-            var discrepancy = 0;
-            var keys = first.Keys.Concat(second.Keys).Distinct();
-
-            foreach (var key in keys)
-            {
-                if (first.ContainsKey(key) && second.ContainsKey(key))
-                {
-                    discrepancy += Math.Abs(first[key] - second[key]);
-                }
-                else if (first.ContainsKey(key))
-                {
-                    discrepancy += first[key];
-                }
-                else
-                {
-                    discrepancy += second[key];
-                }
-            }
-
-            return discrepancy;
-        }
-
-        private void DetermineUniqueItems(Expression source, IDictionary<int, int> items)
-        {
-            if (source.GetType() == typeof(ExecExpandExpression))
-            {
-                var expand = source as ExecExpandExpression;
-
-                foreach (var e in expand.Expressions)
-                {
-                    var id = e.GetHashCode();
-                    if (!items.ContainsKey(id))
-                    {
-                        items.Add(id, 1);
-                    }
-                    else
-                    {
-                        items[id]++;
-                    }
-                }
-            }
-            else
-            {
-                items.Add(source.GetHashCode(), 1);
-            }
-        }
-    }
-
-
-    /// <summary>
-    /// Pushes the sub-expression of the top item of the CODE stack that is indexed by the top item of the INTEGER stack.
-    /// The indexing here counts "points," where each parenthesized expression and each literal/instruction is considered a point,
-    /// and it proceeds in depth first order. The entire piece of code is at index 0; if it is a list then the first item in the list
-    /// is at index 1, etc. The integer used as the index is taken modulo the number of points in the overall expression (and its
-    /// absolute value is taken in case it is negative) to ensure that it is within the meaningful range.
-    /// </summary>
-    public class CodeExtractExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.EXTRACT";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0 ||
-                interpreter.CodeStack.Count == 0 ||
-                interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))
-            {
-                return;
-            }
-
-            var expression = interpreter.CodeStack.Top as ExecExpandExpression;
-            var index = (int)Math.Abs(interpreter.IntegerStack.Pop() % expression.TotalCount);
-            var result = expression.GetFromTree(index);
-
-            interpreter.CodeStack.SetTop(result);
-        }
-    }
-
-    /// <summary>
-    /// Pops the BOOLEAN stack and pushes the popped item (TRUE or FALSE) onto the CODE stack.
-    /// </summary>
-    public class CodeFromBooleanExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.FROMBOOLEAN";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.BooleanStack.Count == 0)
-                return;
-
-            var value = interpreter.BooleanStack.Pop();
-            var expression = new BooleanPushExpression(value);
-
-            interpreter.CodeStack.Push(expression);
-        }
-    }
-
-    /// <summary>
-    /// Pops the FLOAT stack and pushes the popped item onto the CODE stack.
-    /// </summary>
-    public class CodeFromFloatExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.FROMFLOAT";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.FloatStack.Count == 0)
-                return;
-
-            var value = interpreter.FloatStack.Pop();
-            var expression = new FloatPushExpression(value);
-
-            interpreter.CodeStack.Push(expression);
-        }
-    }
-
-    /// <summary>
-    /// Pops the INTEGER stack and pushes the popped integer onto the CODE stack.
-    /// </summary>
-    public class CodeFromIntegerExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.FROMINTEGER";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0)
-                return;
-
-            var value = interpreter.IntegerStack.Pop();
-            var expression = new IntegerPushExpression(value);
-
-            interpreter.CodeStack.Push(expression);
-        }
-    }
-
-    /// <summary>
-    /// Pops the NAME stack and pushes the popped item onto the CODE stack.
-    /// </summary>
-    public class CodeFromNameExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.FROMNAME";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.NameStack.Count == 0)
-                return;
-
-            var value = interpreter.NameStack.Pop();
-            var expression = new NameDefineXExecExpression(value);
-
-            interpreter.CodeStack.Push(expression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the result of inserting the second item of the CODE stack into the first item, at the position indexed
-    /// by the top item of the INTEGER stack (and replacing whatever was there formerly).
-    /// </summary>
-    public class CodeInsertExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.INSERT";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0 ||
-                interpreter.CodeStack.Count < 2 ||
-                interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))
-                return;
-
-            var source = interpreter.CodeStack[interpreter.CodeStack.Count - 2];
-            var target = interpreter.CodeStack.Pop() as ExecExpandExpression;
-            var index = interpreter.IntegerStack.Pop();
-            Expression result = null;
-
-            if (target.Expressions.Length > 0)
-            {
-                index = target.Expressions.Length - 1 - (Math.Abs(index % target.Expressions.Length));
-                target.Expressions[index] = source;
-                result = target;
-            }
-            else
-            {
-                result = new ExecExpandExpression(new[] { source });
-            }
-
-            interpreter.CodeStack.SetTop(result);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the length of the top item on the CODE stack onto the INTEGER stack.
-    /// If the top item is not a list then this pushes a 1. If the top item is a list then this pushes the
-    /// number of items in the top level of the list; that is, nested lists contribute only 1 to this count, no
-    /// matter what they contain.
-    /// </summary>
-    public class CodeLengthExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.LENGTH";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            var expression = interpreter.CodeStack.Pop();
-            var count = 1;
-
-            if (expression.GetType() == typeof(ExecExpandExpression))
-            {
-                count = (expression as ExecExpandExpression).Expressions.Length;
-            }
-
-            interpreter.IntegerStack.Push(count);
-        }
-    }
-
-    /// <summary>
-    /// Pushes a list of the top two items of the CODE stack onto the CODE stack.
-    /// </summary>
-    public class CodeListExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.LIST";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2)
-                return;
-
-            var first = interpreter.CodeStack.Pop();
-            var second = interpreter.CodeStack.Top;
-
-            var expandExpression = ExecExpandExpression.TryCreate(new[]
-            {
-                second,
-                first
-            }, interpreter.Configuration);
-
-            interpreter.CodeStack.SetTop(expandExpression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the second item of the CODE stack is a member of the first item
-    /// (which is coerced to a list if necessary). Pushes FALSE onto the BOOLEAN stack otherwise.
-    /// </summary>
-    public class CodeMemberExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.MEMBER";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2)
-                return;
-
-            var expressions = interpreter.CodeStack.Pop(2);
-
-            var contains = expressions[1].GetType() == typeof(ExecExpandExpression)
-                ? (expressions[1] as ExecExpandExpression).Expressions.Contains(expressions[0])
-                : expressions[1].Equals(expressions[0]);
-
-            interpreter.BooleanStack.Push(contains);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the nth element of the expression on top of the CODE stack (which is coerced to a list first if necessary).
-    /// If the expression is an empty list then the result is an empty list. N is taken from the INTEGER stack and is taken
-    /// modulo the length of the expression into which it is indexing.
-    /// </summary>
-    public class CodeNthExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.NTH";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0 ||
-                interpreter.IntegerStack.Count == 0)
-                return;
-
-            var n = interpreter.IntegerStack.Pop();
-            var expression = interpreter.CodeStack.Top;
-
-            Expression nthExpression = null;
-
-            if (expression.GetType() == typeof(ExecExpandExpression))
-            {
-                var subExpression = expression as ExecExpandExpression;
-
-                nthExpression = subExpression.IsEmpty
-                    ? ExecExpandExpression.Empty
-                    : subExpression.Expressions[subExpression.Expressions.Length - 1 - Math.Abs(n % subExpression.Expressions.Length)];
-            }
-            else
-            {
-                nthExpression = expression;
-            }
-
-            interpreter.CodeStack.SetTop(nthExpression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the nth "CDR" (in the Lisp sense) of the expression on top of the CODE stack (which is coerced to a list
-    /// first if necessary). If the expression is an empty list then the result is an empty list. N is taken from the INTEGER
-    /// stack and is taken modulo the length of the expression into which it is indexing. A "CDR" of a list is the list without
-    /// its first element.
-    /// </summary>
-    public class CodeNthCdrExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.NTHCDR";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0 ||
-                interpreter.IntegerStack.Count == 0)
-                return;
-
-            var n = interpreter.IntegerStack.Pop();
-            var expression = interpreter.CodeStack.Top;
-
-            Expression nthExpression = null;
-
-            if (expression.GetType() == typeof(ExecExpandExpression))
-            {
-                var subExpressions = (expression as ExecExpandExpression).Expressions;
-
-                nthExpression = subExpressions.Length < 2
-                    ? ExecExpandExpression.Empty
-                    : subExpressions[subExpressions.Length - 2 - Math.Abs(n % (subExpressions.Length - 1))];
-            }
-            else
-            {
-                nthExpression = expression;
-            }
-
-            interpreter.CodeStack.SetTop(nthExpression);
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the top item of the CODE stack is an empty list, or FALSE otherwise.
-    /// </summary>
-    public class CodeNullExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.NULL";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            var result = interpreter.CodeStack.Pop().Equals(ExecExpandExpression.Empty);
-
-            interpreter.BooleanStack.Push(result);
-        }
-    }
-
-    /// <summary>
-    /// Pushes onto the INTEGER stack the position of the second item on the CODE stack within the first item
-    /// (which is coerced to a list if necessary). Pushes -1 if no match is found.
-    /// </summary>
-    public class CodePositionExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.POSITION";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 2)
-                return;
-
-            var expressions = interpreter.CodeStack.Pop(2);
-            var first = expressions[1];
-            var second = expressions[0];
-
-            var position = -1;
-            if (first.GetType() == typeof(ExecExpandExpression))
-            {
-                var expand = first as ExecExpandExpression;
-                position = expand.Expressions.Length - 1 - Array.FindIndex(expand.Expressions, e => e.Equals(second));
-            }
-            else if (first.Equals(second))
-            {
-                position = 0;
-            }
-
-            interpreter.IntegerStack.Push(position);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the number of "points" in the top piece of CODE onto the INTEGER stack. Each instruction, literal,
-    /// and pair of parentheses counts as a point.
-    /// </summary>
-    public class CodeSizeExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.SIZE";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count == 0)
-                return;
-
-            var expression = interpreter.CodeStack.Pop();
-            var points = expression.GetType() == typeof(ExecExpandExpression)
-                ? (expression as ExecExpandExpression).Expressions.Length
-                : 1;
-
-            interpreter.IntegerStack.Push(points);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the result of substituting the third item on the code stack for the second item in the first item.
-    /// As of this writing this is implemented only in the Lisp implementation, within which it relies on the Lisp "subst"
-    /// function. As such, there are several problematic possibilities; for example "dotted-lists" can result in certain
-    /// cases with empty-list arguments. If any of these problematic possibilities occurs the stack is left unchanged.
-    /// </summary>
-    public class CodeSubstitutionExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.SUBST";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.CodeStack.Count < 3 ||
-                interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))
-                return;
-
-            var expressions = interpreter.CodeStack.Pop(2);
-            var third = interpreter.CodeStack.Top;
-            var second = expressions[0];
-            var first = expressions[1] as ExecExpandExpression;
-
-
-            for (var i = 0; i < first.Expressions.Length; i++)
-            {
-                if (first.Expressions[i].Equals(third))
-                {
-                    first.Expressions[i] = second;
-                }
-            }
-
-            interpreter.CodeStack.SetTop(first);
-        }
-    }
-
+      } else {
+        nthExpression = expression;
+      }
+
+      interpreter.CodeStack.SetTop(nthExpression);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the top item of the CODE stack is an empty list, or FALSE otherwise.
+  /// </summary>
+  public class CodeNullExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.NULL";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count == 0) return;
+
+      var result = interpreter.CodeStack.Pop().Equals(ExecExpandExpression.Empty);
+
+      interpreter.BooleanStack.Push(result);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes onto the INTEGER stack the position of the second item on the CODE stack within the first item
+  ///     (which is coerced to a list if necessary). Pushes -1 if no match is found.
+  /// </summary>
+  public class CodePositionExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.POSITION";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count < 2) return;
+
+      var expressions = interpreter.CodeStack.Pop(2);
+      var first = expressions[1];
+      var second = expressions[0];
+
+      var position = -1;
+      if (first.GetType() == typeof(ExecExpandExpression)) {
+        var expand = first as ExecExpandExpression;
+        position = expand.Expressions.Count - 1
+                   - Array.FindIndex(expand.Expressions as Expression[], e => e.Equals(second));
+      } else if (first.Equals(second)) {
+        position = 0;
+      }
+
+      interpreter.IntegerStack.Push(position);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the number of "points" in the top piece of CODE onto the INTEGER stack. Each instruction, literal,
+  ///     and pair of parentheses counts as a point.
+  /// </summary>
+  public class CodeSizeExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.SIZE";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.CodeStack.Count == 0) return;
+
+      var expression = interpreter.CodeStack.Pop();
+      var points = expression.GetType() == typeof(ExecExpandExpression)
+                     ? (expression as ExecExpandExpression).Expressions.Count
+                     : 1;
+
+      interpreter.IntegerStack.Push(points);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the result of substituting the third item on the code stack for the second item in the first item.
+  ///     As of this writing this is implemented only in the Lisp implementation, within which it relies on the Lisp "subst"
+  ///     function. As such, there are several problematic possibilities; for example "dotted-lists" can result in certain
+  ///     cases with empty-list arguments. If any of these problematic possibilities occurs the stack is left unchanged.
+  /// </summary>
+  public class CodeSubstitutionExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.SUBST";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if ((interpreter.CodeStack.Count < 3) || (interpreter.CodeStack.Top.GetType() != typeof(ExecExpandExpression))) return;
+
+      var expressions = interpreter.CodeStack.Pop(2);
+      var third = interpreter.CodeStack.Top;
+      var second = expressions[0];
+      var first = expressions[1] as ExecExpandExpression;
+      var newExpressions = new Expression[first.Expressions.Count];
+
+      for (var i = 0; i < first.Expressions.Count; i++)
+        newExpressions[i] = first.Expressions[i].Equals(third)
+                              ? second
+                              /* no cloning needed here because first is removed and therefore newExpression is the
+             only container of sub expressions */
+                              : first.Expressions[i];
+
+      var result = new ExecExpandExpression(newExpressions);
+
+      interpreter.CodeStack.SetTop(result);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DefineExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DefineExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DefineExpressions.cs	(revision 14513)
@@ -1,130 +1,125 @@
-﻿using System;
-using System.Collections.Generic;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using System;
+  using System.Collections.Generic;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Defines the name on top of the NAME stack as an instruction that will push the top item of the T stack onto the EXEC stack.
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class DefineExpression<T> : StatelessExpression
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  /// <summary>
+  ///     Defines the name on top of the NAME stack as an instruction that will push the top item of the T stack onto the
+  ///     EXEC stack.
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class DefineExpression<T> : StatelessExpression
+  {
+    protected void Eval(
+      IStack<T> stack,
+      IStack<string> nameStack,
+      IDictionary<string, Expression> customExpressions,
+      Func<T, Expression> creator)
     {
-        protected void Eval(IStack<T> stack, IStack<string> nameStack, IDictionary<string, Expression> customExpressions, Func<T, Expression> creator)
-        {
-            // not enough arguments on stack
-            if (nameStack.Count == 0 ||
-                stack.Count < 1)
-                return;
+      // not enough arguments on stack
+      if ((nameStack.Count == 0) || (stack.Count < 1)) return;
 
-            var name = nameStack.Pop();
-            var expression = creator(stack.Top);
+      var name = nameStack.Pop();
+      var expression = creator(stack.Top);
 
-            if (customExpressions.ContainsKey(name))
-            {
-                customExpressions[name] = expression;
-            }
-            else
-            {
-                customExpressions.Add(name, expression);
-            }
-        }
+      if (customExpressions.ContainsKey(name)) customExpressions[name] = expression;
+      else customExpressions.Add(name, expression);
+    }
+  }
+
+  public class CodeDefineExpression : DefineExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.DEFINE";
     }
 
-    public class CodeDefineExpression : DefineExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DEFINE";
-        }
+      if (interpreter.Configuration.TopLevelPushCode && (interpreter.CodeStack.Count < 2)) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.Configuration.TopLevelPushCode &&
-                interpreter.CodeStack.Count < 2)
-                return;
+      this.Eval(
+        interpreter.CodeStack,
+        interpreter.NameStack,
+        interpreter.CustomExpressions,
+        v => new ExecPushExpression(v));
 
-            Eval(
-                interpreter.CodeStack,
-                interpreter.NameStack,
-                interpreter.CustomExpressions,
-                v => new ExecPushExpression(v));
+      interpreter.CodeStack.Pop();
+    }
+  }
 
-            interpreter.CodeStack.Pop();
-        }
+  public class ExecDefineExpression : DefineExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.DEFINE";
     }
 
-    public class ExecDefineExpression : DefineExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation()
-        {
-            return "EXEC.DEFINE";
-        }
+      if (interpreter.ExecStack.Count < 2) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.ExecStack.Count < 2)
-                return;
+      this.Eval(
+        interpreter.ExecStack,
+        interpreter.NameStack,
+        interpreter.CustomExpressions,
+        v => new ExecPushExpression(v));
 
-            Eval(
-                interpreter.ExecStack,
-                interpreter.NameStack,
-                interpreter.CustomExpressions,
-                v => new ExecPushExpression(v));
+      interpreter.ExecStack.Pop();
+    }
+  }
 
-            interpreter.ExecStack.Pop();
-        }
+  public class FloatDefineExpression : DefineExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.DEFINE";
     }
 
-    public class FloatDefineExpression : DefineExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation()
-        {
-            return "FLOAT.DEFINE";
-        }
+      this.Eval(
+        interpreter.FloatStack,
+        interpreter.NameStack,
+        interpreter.CustomExpressions,
+        v => new FloatPushExpression(v));
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.FloatStack,
-                interpreter.NameStack,
-                interpreter.CustomExpressions,
-                v => new FloatPushExpression(v));
-        }
+  public class IntegerDefineExpression : DefineExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.DEFINE";
     }
 
-    public class IntegerDefineExpression : DefineExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation()
-        {
-            return "INTEGER.DEFINE";
-        }
+      this.Eval(
+        interpreter.IntegerStack,
+        interpreter.NameStack,
+        interpreter.CustomExpressions,
+        v => new IntegerPushExpression(v));
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.IntegerStack,
-                interpreter.NameStack,
-                interpreter.CustomExpressions,
-                v => new IntegerPushExpression(v));
-        }
+  public class BooleanDefineExpression : DefineExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.DEFINE";
     }
 
-    public class BooleanDefineExpression : DefineExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation()
-        {
-            return "BOOLEAN.DEFINE";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.BooleanStack,
-                interpreter.NameStack,
-                interpreter.CustomExpressions,
-                v => new BooleanPushExpression(v));
-        }
+      this.Eval(
+        interpreter.BooleanStack,
+        interpreter.NameStack,
+        interpreter.CustomExpressions,
+        v => new BooleanPushExpression(v));
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoCountExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoCountExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoCountExpressions.cs	(revision 14513)
@@ -1,97 +1,66 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class DoCountExpression : LoopExpression
-    {
-        public DoCountExpression()
-        { }
-
-        public DoCountExpression(LoopExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
-
-        protected override bool HasInsufficientArguments(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            return interpreter.IntegerStack.Count < 1 ||
-                   sourceStack.Count == 0 ||
-                   interpreter.IntegerStack.Top <= 0;
-        }
-
-        protected override void InitState(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            body = sourceStack.Pop();
-            destinationIndex = interpreter.IntegerStack.Top;
-            currentIndex = 1;
-            incrementor = 1;
-
-            interpreter.IntegerStack.SetTop(0);
-        }
+  public abstract class DoCountExpression : LoopExpression {
+    protected override bool HasInsufficientArguments(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      return (interpreter.IntegerStack.Count < 1) || (sourceStack.Count == 0) || (interpreter.IntegerStack.Top <= 0);
     }
 
-    /// <summary>
-    /// An iteration instruction that performs a loop (the body of which is taken from the CODE stack) the number of times indicated by
-    /// the INTEGER argument, pushing an index (which runs from zero to one less than the number of iterations) onto the INTEGER stack
-    /// prior to each execution of the loop body. This should be implemented as a macro that expands into a call to CODE.DO*RANGE.
-    /// CODE.DO*COUNT takes a single INTEGER argument (the number of times that the loop will be executed) and a single CODE argument
-    /// (the body of the loop). If the provided INTEGER argument is negative or zero then this becomes a NOOP. Otherwise it expands into:
-    /// ( 0 '1 - IntegerArg>' CODE.QUOTE 'CodeArg' CODE.DO*RANGE )
-    /// </summary>
-    public class CodeDoCountExpression : DoCountExpression
-    {
-        public CodeDoCountExpression()
-        { }
+    protected override void InitState(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      this.State.Body = sourceStack.Pop();
+      this.State.DestinationIndex = interpreter.IntegerStack.Top;
+      this.State.CurrentIndex = 1;
+      this.State.Incrementor = 1;
 
-        protected CodeDoCountExpression(CodeDoCountExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
+      interpreter.IntegerStack.SetTop(0);
+    }
+  }
 
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new CodeDoCountExpression(this, cloner);
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DO*COUNT";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.CodeStack);
-        }
+  /// <summary>
+  ///     An iteration instruction that performs a loop (the body of which is taken from the CODE stack) the number of times
+  ///     indicated by
+  ///     the INTEGER argument, pushing an index (which runs from zero to one less than the number of iterations) onto the
+  ///     INTEGER stack
+  ///     prior to each execution of the loop body. This should be implemented as a macro that expands into a call to
+  ///     CODE.DO*RANGE.
+  ///     CODE.DO*COUNT takes a single INTEGER argument (the number of times that the loop will be executed) and a single
+  ///     CODE argument
+  ///     (the body of the loop). If the provided INTEGER argument is negative or zero then this becomes a NOOP. Otherwise it
+  ///     expands into:
+  ///     ( 0 '1 - IntegerArg>' CODE.QUOTE 'CodeArg' CODE.DO*RANGE )
+  /// </summary>
+  public class CodeDoCountExpression : DoCountExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DO*COUNT";
     }
 
-    /// <summary>
-    /// An iteration instruction that performs a loop (the body of which is taken from the EXEC stack) the number of times indicated
-    /// by the INTEGER argument, pushing an index (which runs from zero to one less than the number of iterations) onto the INTEGER
-    /// stack prior to each execution of the loop body. This is similar to CODE.DO*COUNT except that it takes its code argument from
-    /// the EXEC stack. This should be implemented as a macro that expands into a call to EXEC.DO*RANGE. EXEC.DO*COUNT takes a single
-    /// INTEGER argument (the number of times that the loop will be executed) and a single EXEC argument (the body of the loop). If
-    /// the provided INTEGER argument is negative or zero then this becomes a NOOP. Otherwise it expands into:
-    /// ( 0 '1 - IntegerArg' EXEC.DO* RANGE'ExecArg' )
-    /// </summary>
-    public class ExecDoCountExpression : DoCountExpression
-    {
-        public ExecDoCountExpression()
-        { }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.CodeStack);
+    }
+  }
 
-        protected ExecDoCountExpression(ExecDoCountExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
+  /// <summary>
+  ///     An iteration instruction that performs a loop (the body of which is taken from the EXEC stack) the number of times
+  ///     indicated
+  ///     by the INTEGER argument, pushing an index (which runs from zero to one less than the number of iterations) onto the
+  ///     INTEGER
+  ///     stack prior to each execution of the loop body. This is similar to CODE.DO*COUNT except that it takes its code
+  ///     argument from
+  ///     the EXEC stack. This should be implemented as a macro that expands into a call to EXEC.DO*RANGE. EXEC.DO*COUNT
+  ///     takes a single
+  ///     INTEGER argument (the number of times that the loop will be executed) and a single EXEC argument (the body of the
+  ///     loop). If
+  ///     the provided INTEGER argument is negative or zero then this becomes a NOOP. Otherwise it expands into:
+  ///     ( 0 '1 - IntegerArg' EXEC.DO* RANGE'ExecArg' )
+  /// </summary>
+  public class ExecDoCountExpression : DoCountExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.DO*COUNT";
+    }
 
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new ExecDoCountExpression(this, cloner);
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return "EXEC.DO*COUNT";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.ExecStack);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.ExecStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoRangeExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoRangeExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoRangeExpressions.cs	(revision 14513)
@@ -1,106 +1,85 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class DoRangeExpression : LoopExpression
-    {
-        public DoRangeExpression()
-        { }
-
-        public DoRangeExpression(LoopExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
-
-        protected override bool HasInsufficientArguments(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            return interpreter.IntegerStack.Count < 2 ||
-                   sourceStack.Count == 0 ||
-                   interpreter.IntegerStack.Top == interpreter.IntegerStack.ReverseElementAt(1);
-        }
-
-        protected override void InitState(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            body = sourceStack.Pop();
-            destinationIndex = interpreter.IntegerStack.Pop();
-            currentIndex = interpreter.IntegerStack.Top;
-            incrementor = destinationIndex < currentIndex ? -1 : 1;
-            currentIndex += incrementor;
-        }
+  public abstract class DoRangeExpression : LoopExpression {
+    protected override bool HasInsufficientArguments(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      return (interpreter.IntegerStack.Count < 2) || (sourceStack.Count == 0)
+             || (interpreter.IntegerStack.Top == interpreter.IntegerStack.ReverseElementAt(1));
     }
 
-    /// <summary>
-    /// An iteration instruction that executes the top item on the CODE stack a number of times that depends on the
-    /// top two integers, while also pushing the loop counter onto the INTEGER stack for possible access during the execution of
-    /// the body of the loop. The top integer is the "destination index" and the second integer is the "current index." First the code
-    /// and the integer arguments are saved locally and popped. Then the integers are compared. If the integers are equal then the current
-    /// index is pushed onto the INTEGER stack and the code (which is the "body" of the loop) is pushed onto the EXEC stack for subsequent
-    /// execution. If the integers are not equal then the current index will still be pushed onto the INTEGER stack but two items will be
-    /// pushed onto the EXEC stack -- first a recursive call to CODE.DO*RANGE (with the same code and destination index, but with a current
-    /// index that has been either incremented or decremented by 1 to be closer to the destination index) and then the body code. Note that
-    /// the range is inclusive of both endpoints; a call with integer arguments 3 and 5 will cause its body to be executed 3 times, with the
-    /// loop counter having the values 3, 4, and 5. Note also that one can specify a loop that "counts down" by providing a destination index
-    /// that is less than the specified current index.
-    /// </summary>
-    public class CodeDoRangeExpression : DoRangeExpression
-    {
-        public CodeDoRangeExpression()
-        { }
+    protected override void InitState(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      this.State.Body = sourceStack.Pop();
+      this.State.DestinationIndex = interpreter.IntegerStack.Pop();
+      this.State.CurrentIndex = interpreter.IntegerStack.Top;
+      this.State.Incrementor = this.State.DestinationIndex < this.State.CurrentIndex ? -1 : 1;
+      this.State.CurrentIndex += this.State.Incrementor;
+    }
+  }
 
-        protected CodeDoRangeExpression(CodeDoRangeExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new CodeDoRangeExpression(this, cloner);
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DO*RANGE";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.CodeStack);
-        }
+  /// <summary>
+  ///     An iteration instruction that executes the top item on the CODE stack a number of times that depends on the
+  ///     top two integers, while also pushing the loop counter onto the INTEGER stack for possible access during the
+  ///     execution of
+  ///     the body of the loop. The top integer is the "destination index" and the second integer is the "current index."
+  ///     First the code
+  ///     and the integer arguments are saved locally and popped. Then the integers are compared. If the integers are equal
+  ///     then the current
+  ///     index is pushed onto the INTEGER stack and the code (which is the "body" of the loop) is pushed onto the EXEC stack
+  ///     for subsequent
+  ///     execution. If the integers are not equal then the current index will still be pushed onto the INTEGER stack but two
+  ///     items will be
+  ///     pushed onto the EXEC stack -- first a recursive call to CODE.DO*RANGE (with the same code and destination index,
+  ///     but with a current
+  ///     index that has been either incremented or decremented by 1 to be closer to the destination index) and then the body
+  ///     code. Note that
+  ///     the range is inclusive of both endpoints; a call with integer arguments 3 and 5 will cause its body to be executed
+  ///     3 times, with the
+  ///     loop counter having the values 3, 4, and 5. Note also that one can specify a loop that "counts down" by providing a
+  ///     destination index
+  ///     that is less than the specified current index.
+  /// </summary>
+  public class CodeDoRangeExpression : DoRangeExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DO*RANGE";
     }
 
-    /// <summary>
-    /// An iteration instruction that executes the top item on the EXEC stack a number of times that depends on the top two integers,
-    /// while also pushing the loop counter onto the INTEGER stack for possible access during the execution of the body of the loop.
-    /// This is similar to CODE.DO*COUNT except that it takes its code argument from the EXEC stack. The top integer is the
-    /// "destination index" and the second integer is the "current index." First the code and the integer arguments are saved locally
-    /// and popped. Then the integers are compared. If the integers are equal then the current index is pushed onto the INTEGER stack
-    /// and the code (which is the "body" of the loop) is pushed onto the EXEC stack for subsequent execution. If the integers are not
-    /// equal then the current index will still be pushed onto the INTEGER stack but two items will be pushed onto the EXEC stack
-    /// -- first a recursive call to EXEC.DO*RANGE (with the same code and destination index, but with a current index that has been
-    /// either incremented or decremented by 1 to be closer to the destination index) and then the body code. Note that the range is
-    /// inclusive of both endpoints; a call with integer arguments 3 and 5 will cause its body to be executed 3 times, with the loop
-    /// counter having the values 3, 4, and 5. Note also that one can specify a loop that "counts down" by providing a destination
-    /// index that is less than the specified current index.
-    /// </summary>
-    public class ExecDoRangeExpression : DoRangeExpression
-    {
-        public ExecDoRangeExpression()
-        { }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.CodeStack);
+    }
+  }
 
-        protected ExecDoRangeExpression(ExecDoRangeExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
+  /// <summary>
+  ///     An iteration instruction that executes the top item on the EXEC stack a number of times that depends on the top two
+  ///     integers,
+  ///     while also pushing the loop counter onto the INTEGER stack for possible access during the execution of the body of
+  ///     the loop.
+  ///     This is similar to CODE.DO*COUNT except that it takes its code argument from the EXEC stack. The top integer is the
+  ///     "destination index" and the second integer is the "current index." First the code and the integer arguments are
+  ///     saved locally
+  ///     and popped. Then the integers are compared. If the integers are equal then the current index is pushed onto the
+  ///     INTEGER stack
+  ///     and the code (which is the "body" of the loop) is pushed onto the EXEC stack for subsequent execution. If the
+  ///     integers are not
+  ///     equal then the current index will still be pushed onto the INTEGER stack but two items will be pushed onto the EXEC
+  ///     stack
+  ///     -- first a recursive call to EXEC.DO*RANGE (with the same code and destination index, but with a current index that
+  ///     has been
+  ///     either incremented or decremented by 1 to be closer to the destination index) and then the body code. Note that the
+  ///     range is
+  ///     inclusive of both endpoints; a call with integer arguments 3 and 5 will cause its body to be executed 3 times, with
+  ///     the loop
+  ///     counter having the values 3, 4, and 5. Note also that one can specify a loop that "counts down" by providing a
+  ///     destination
+  ///     index that is less than the specified current index.
+  /// </summary>
+  public class ExecDoRangeExpression : DoRangeExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.DO*RANGE";
+    }
 
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new ExecDoRangeExpression(this, cloner);
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return "EXEC.DO*RANGE";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.ExecStack);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.ExecStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoTimesExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoTimesExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DoTimesExpressions.cs	(revision 14513)
@@ -1,102 +1,60 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class DoTimesExpression : LoopExpression
-    {
-        public DoTimesExpression()
-        { }
-
-        public DoTimesExpression(LoopExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
-
-        protected override bool HasInsufficientArguments(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            return interpreter.IntegerStack.Count < 1 ||
-                   sourceStack.Count == 0 ||
-                   interpreter.IntegerStack.Top <= 0;
-        }
-
-        protected override void InitState(IInterpreter interpreter, IStack<Expression> sourceStack)
-        {
-            body = sourceStack.Pop();
-            destinationIndex = interpreter.IntegerStack.Pop();
-            currentIndex = 1;
-            incrementor = 1;
-        }
-
-        protected override void PushIteration(IInterpreter interpreter)
-        {
-            interpreter.ExecStack.Push(this, body);
-        }
-
-        protected override void PushLastIteration(IInterpreter interpreter)
-        {
-            interpreter.ExecStack.Push(body);
-        }
+  public abstract class DoTimesExpression : LoopExpression {
+    protected override bool HasInsufficientArguments(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      return (interpreter.IntegerStack.Count < 1) || (sourceStack.Count == 0) || (interpreter.IntegerStack.Top <= 0);
     }
 
-    /// <summary>
-    /// Like CODE.DO*COUNT but does not push the loop counter.
-    /// This should be implemented as a macro that expands into CODE.DO*RANGE, similarly to the implementation
-    /// of CODE.DO*COUNT, except that a call to INTEGER.POP should be tacked on to the front of the loop body code
-    /// in the call to CODE.DO*RANGE.
-    /// </summary>
-
-    public class CodeDoTimesExpression : DoTimesExpression
-    {
-        public CodeDoTimesExpression()
-        { }
-
-        protected CodeDoTimesExpression(CodeDoTimesExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new CodeDoTimesExpression(this, cloner);
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return "CODE.DO*TIMES";
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.CodeStack);
-        }
+    protected override void InitState(IPushGpInterpreter interpreter, IStack<Expression> sourceStack) {
+      this.State.Body = sourceStack.Pop();
+      this.State.DestinationIndex = interpreter.IntegerStack.Pop();
+      this.State.CurrentIndex = 1;
+      this.State.Incrementor = 1;
     }
 
-    /// <summary>
-    /// Like EXEC.DO*COUNT but does not push the loop counter. This should be implemented as a macro that expands into EXEC.DO*RANGE,
-    /// similarly to the implementation of EXEC.DO*COUNT, except that a call to INTEGER.POP should be tacked on to the front of the
-    /// loop body code in the call to EXEC.DO*RANGE. This call to INTEGER.POP will remove the loop counter, which will have been
-    /// pushed by EXEC.DO*RANGE, prior to the execution of the loop body.
-    /// </summary>
+    protected override void PushIteration(IPushGpInterpreter interpreter) {
+      interpreter.ExecStack.Push(this, this.State.Body);
+    }
 
-    public class ExecDoTimesExpression : DoTimesExpression
-    {
-        public ExecDoTimesExpression()
-        { }
+    protected override void PushLastIteration(IPushGpInterpreter interpreter) {
+      interpreter.ExecStack.Push(this.State.Body);
+    }
+  }
 
-        protected ExecDoTimesExpression(ExecDoTimesExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
+  /// <summary>
+  ///     Like CODE.DO*COUNT but does not push the loop counter.
+  ///     This should be implemented as a macro that expands into CODE.DO*RANGE, similarly to the implementation
+  ///     of CODE.DO*COUNT, except that a call to INTEGER.POP should be tacked on to the front of the loop body code
+  ///     in the call to CODE.DO*RANGE.
+  /// </summary>
+  public class CodeDoTimesExpression : DoTimesExpression {
+    protected override string InitStringRepresentation() {
+      return "CODE.DO*TIMES";
+    }
 
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new ExecDoTimesExpression(this, cloner);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.CodeStack);
+    }
+  }
 
-        protected override string InitStringRepresentation()
-        {
-            return "EXEC.DO*TIMES";
-        }
+  /// <summary>
+  ///     Like EXEC.DO*COUNT but does not push the loop counter. This should be implemented as a macro that expands into
+  ///     EXEC.DO*RANGE,
+  ///     similarly to the implementation of EXEC.DO*COUNT, except that a call to INTEGER.POP should be tacked on to the
+  ///     front of the
+  ///     loop body code in the call to EXEC.DO*RANGE. This call to INTEGER.POP will remove the loop counter, which will have
+  ///     been
+  ///     pushed by EXEC.DO*RANGE, prior to the execution of the loop body.
+  /// </summary>
+  public class ExecDoTimesExpression : DoTimesExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.DO*TIMES";
+    }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter, interpreter.ExecStack);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter, interpreter.ExecStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DuplicateExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DuplicateExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/DuplicateExpressions.cs	(revision 14513)
@@ -1,81 +1,107 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Duplicates the top item on the INTEGER stack. Does not pop its argument
-    /// (which, if it did, would negate the effect of the duplication!).
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class DuplicateExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Duplicates the top item on the INTEGER stack. Does not pop its argument
+  ///     (which, if it did, would negate the effect of the duplication!).
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class DuplicateExpression<T> : StatelessExpression
+  {
+    protected void Eval(IStack<T> stack)
     {
-        public void Eval(IStack<T> stack)
-        {
-            if (stack.Count == 0)
-                return;
+      if (stack.Count == 0) return;
 
-            stack.Push(stack.Top);
-        }
+      stack.Push(stack.Top);
     }
 
-    public class IntegerDuplicateExpression : DuplicateExpression<long>
+    protected void Eval(IStack<Expression> stack)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.DUP"; }
+      if (stack.Count == 0) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+      var top = stack.Top;
+
+      stack.Push(top);
+    }
+  }
+
+  public class IntegerDuplicateExpression : DuplicateExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.DUP";
     }
 
-    public class FloatDuplicateExpression : DuplicateExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.DUP"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class FloatDuplicateExpression : DuplicateExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.DUP";
     }
 
-    public class BooleanDuplicateExpression : DuplicateExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.DUP"; }
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+  public class BooleanDuplicateExpression : DuplicateExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.DUP";
     }
 
-    public class NameDuplicateExpression : DuplicateExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.DUP"; }
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
+  public class NameDuplicateExpression : DuplicateExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.DUP";
     }
 
-    public class ExecDuplicateExpression : DuplicateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.DUP"; }
+      this.Eval(interpreter.NameStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+  public class ExecDuplicateExpression : DuplicateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.DUP";
     }
 
-    public class CodeDuplicateExpression : DuplicateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.DUP"; }
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack);
-        }
+  public class CodeDuplicateExpression : DuplicateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.DUP";
     }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.CodeStack);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ERCExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ERCExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ERCExpressions.cs	(revision 14513)
@@ -1,104 +1,52 @@
-﻿using System;
-using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Generators;
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class ERCExpression<T> : Expression
-    {
-        private readonly T value;
+  /// <summary>
+  /// ERC expressions are only used for code generation.
+  /// </summary>
+  /// <typeparam name="T"></typeparam>
+  public abstract class ErcExpression<T> : PushExpression<T> {
+    protected ErcExpression(T value) : base(value) { }
 
-        public ERCExpression(T value)
-        {
-            this.value = value;
-        }
-
-        protected void Eval(IStack<T> stack)
-        {
-            stack.Push(value);
-        }
-
-        /// <summary>
-        /// Does not make sense
-        /// </summary>
-        /// <returns></returns>
-        protected override string InitStringRepresentation()
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// Does not make sense
-        /// </summary>
-        /// <returns></returns>
-        protected override int InitId()
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// Does not make sense
-        /// </summary>
-        /// <returns></returns>
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            throw new NotImplementedException();
-        }
+    protected override string InitStringRepresentation() {
+      return string.Format("{0}({1})", this.GetType().Name, this.State);
     }
 
-    public class IntegerERCExpression : ERCExpression<long>
-    {
-        public IntegerERCExpression() : base(IntegerGenerator.RandomInteger())
-        {
-        }
+    protected override int InitId() {
+      return this.State.GetHashCode();
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+  public class IntegerErcExpression : ErcExpression<long> {
+    public IntegerErcExpression() : base(IntegerGenerator.RandomInteger()) { }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.IntegerStack);
     }
+  }
 
-    public class FloatERCExpression : ERCExpression<double>
-    {
-        protected bool isInitialized = false;
+  public class FloatErcExpression : ErcExpression<double> {
+    public FloatErcExpression() : base(FloatGenerator.RandomFloat()) { }
 
-        public FloatERCExpression() : base(FloatGenerator.RandomFloat())
-        {
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class BooleanErcExpression : ErcExpression<bool> {
+    public BooleanErcExpression() : base(BooleanGenerator.RandomBoolean()) { }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack);
     }
+  }
 
-    public class BooleanERCExpression : ERCExpression<bool>
-    {
-        public BooleanERCExpression() : base(BooleanGenerator.RandomBoolean())
-        {
-        }
+  public class NameErcExpression : ErcExpression<string> {
+    public NameErcExpression() : base(NameGenerator.RandomName()) { }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.NameStack);
     }
-
-    public class NameERCExpression : ERCExpression<string>
-    {
-        private static IRandom random = new FastRandom();
-
-        public NameERCExpression() : base(NameGenerator.RandomName())
-        {
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
-    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/EqualsExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/EqualsExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/EqualsExpressions.cs	(revision 14513)
@@ -1,82 +1,99 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the top two items are equal, or FALSE otherwise
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class EqualsExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the top two items are equal, or FALSE otherwise
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class EqualsExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack, IStack<bool> booleanStack)
     {
-        public void Eval(IStack<T> stack, IStack<bool> booleanStack)
-        {
-            if (stack.Count < 2)
-                return;
+      if (stack.Count < 2) return;
 
-            var items = stack.Pop(2);
+      var items = stack.Pop(2);
 
-            booleanStack.Push(items[0].Equals(items[1]));
-        }
+      booleanStack.Push(items[0].Equals(items[1]));
+    }
+  }
+
+  public class IntegerEqualsExpression : EqualsExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.=";
     }
 
-    public class IntegerEqualsExpression : EqualsExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.="; }
+      this.Eval(interpreter.IntegerStack, interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, interpreter.BooleanStack);
-        }
+  public class FloatEqualsExpression : EqualsExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.=";
     }
 
-    public class FloatEqualsExpression : EqualsExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.="; }
+      this.Eval(interpreter.FloatStack, interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, interpreter.BooleanStack);
-        }
+  public class BooleanEqualsExpression : EqualsExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.=";
     }
 
-    public class BooleanEqualsExpression : EqualsExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.="; }
+      this.Eval(interpreter.BooleanStack, interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, interpreter.BooleanStack);
-        }
+  public class NameEqualsExpression : EqualsExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.=";
     }
 
-    public class NameEqualsExpression : EqualsExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.="; }
+      this.Eval(interpreter.NameStack, interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack, interpreter.BooleanStack);
-        }
+  public class ExecEqualsExpression : EqualsExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.=";
     }
 
-    public class ExecEqualsExpression : EqualsExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.="; }
+      this.Eval(interpreter.ExecStack, interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack, interpreter.BooleanStack);
-        }
+  public class CodeEqualsExpression : EqualsExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.=";
     }
 
-    public class CodeEqualsExpression : EqualsExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.="; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack, interpreter.BooleanStack);
-        }
+      this.Eval(interpreter.CodeStack, interpreter.BooleanStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExecExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExecExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExecExpressions.cs	(revision 14513)
@@ -1,266 +1,272 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Common;
-
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public class ExecExpandExpression : StatefullExpression
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using System;
+  using System.Collections.Generic;
+  using System.Linq;
+  using System.Text;
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  public class ExecExpandExpression : StatefullExpression<Expression[]> {
+    private const string PREFIX = "( ";
+    private const string POSTFIX = ")";
+    private const string DELIMITER = " ";
+
+    public readonly int Depth;
+
+    public static readonly ExecExpandExpression Empty = new ExecExpandExpression(new Expression[0]);
+
+    public bool IsEmpty { get; private set; }
+
+    private int[] treeIndex;
+
+    public ExecExpandExpression(Expression[] state)
+      : base(state) {
+      this.IsEmpty = this.State.Length == 0;
+      this.InitId();
+
+      var subExpressions = state.Where(e => e.GetType() == typeof(ExecExpandExpression));
+
+      this.Depth = subExpressions.Any() ? subExpressions.Select(e => e as ExecExpandExpression).Max(e => e.Depth) : 1;
+    }
+
+    //private void CheckIfNested(int level, Expression parent)
+    //{
+    //    for (var i = 0; i < State.Length; i++)
+    //    {
+    //        if (State[i].GetType() == typeof(ExecExpandExpression))
+    //        {
+    //            if (parent == State[i])
+    //            {
+    //                Debugger.Break();
+    //            }
+
+    //            (State[i] as ExecExpandExpression).CheckIfNested(level + 1, parent);
+    //        }
+    //    }
+    //}
+
+    public ExecExpandExpression(ExecExpandExpression origin) : base(new Expression[origin.State.Length]) {
+      Array.Copy(origin.State, this.State, origin.State.Length);
+
+      this.IsEmpty = origin.IsEmpty;
+    }
+
+    public IReadOnlyList<Expression> Expressions { get { return this.State; } }
+
+    /// <summary>
+    /// Returns the amount of elements in the whole tree
+    /// </summary>
+    /// <returns></returns>
+    public int TotalCount
     {
-        private const string prefix = "( ";
-        private const string postfix = ")";
-        private const string delimiter = " ";
-
-        public readonly Expression[] Expressions;
-        public readonly bool IsEmpty;
-
-        private List<Expression> treeIndex;
-
-        public static readonly Expression Empty = new ExecExpandExpression(new Expression[0]);
-
-        public ExecExpandExpression(Expression[] expressions)
-        {
-            Expressions = expressions;
-            IsEmpty = expressions.Length == 0;
+      get
+      {
+        if (this.IsEmpty) {
+          return 1;
         }
 
-        // copy constructor
-        public ExecExpandExpression(ExecExpandExpression original, Cloner cloner) : base(original, cloner)
-        {
-            Expressions = new Expression[original.Expressions.Length];
-            Array.Copy(original.Expressions, Expressions, original.Expressions.Length);
-
-            if (original.treeIndex != null)
-            {
-                treeIndex = original.treeIndex.Select(e => cloner.Clone(e)).ToList();
-            }
-
-            IsEmpty = original.IsEmpty;
+        this.BuildIndexIfNecessary();
+
+        // + 1 because this is also counted
+        return this.treeIndex[0] + 1;
+      }
+    }
+
+    protected override string InitStringRepresentation() {
+      var sb = new StringBuilder();
+
+      sb.Append(PREFIX);
+#if DEBUG
+      for (var i = this.State.Length - 1; i >= 0; i--)
+        sb.Append(this.State[i] + DELIMITER);
+#else
+      sb.Append(this.TotalCount.ToString() + DELIMITER);
+#endif
+
+      sb.Append(POSTFIX);
+
+      return sb.ToString();
+    }
+
+    protected sealed override int InitId() {
+      var hash = 19 * 31 + this.GetType().GetHashCode();
+
+      for (var i = this.State.Length - 1; i >= 0; i--) hash = hash * 31 + this.State[i].GetHashCode();
+
+      return hash;
+    }
+
+    public ExecExpandExpression Copy() {
+      // as the empty list is a static stateless expression, no copy required
+      return this == Empty || this.IsEmpty
+        ? Empty
+        : new ExecExpandExpression(this.State);
+    }
+
+    public Expression[] CopyExpressions() {
+      var copy = new Expression[this.State.Length];
+      Array.Copy(this.State, copy, this.State.Length);
+
+      return copy;
+    }
+
+    public override int GetHashCode() {
+      return base.GetHashCode();
+    }
+
+    public override string ToString() {
+      return this.StringRepresentation;
+    }
+
+    public override bool Equals(object obj) {
+      if ((obj == null) || (obj.GetType() != typeof(ExecExpandExpression))) return false;
+
+      return this.GetHashCode() == obj.GetHashCode();
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      interpreter.ExecStack.Push(this.State);
+    }
+
+    /// <summary>
+    ///     Returns the element with the given index whereby the tree is indexed in depth first manner
+    /// </summary>
+    /// <param name="index">The index of the required element</param>
+    /// <returns>The required element</returns>
+    public Expression GetFromTree(int index) {
+      return this.GetFromTree(index, (root, parent, child, childIndex, parentIndex) => child);
+    }
+
+    /// <returns>The required element</returns>
+    public T GetFromTree<T>(int index, Func<ExecExpandExpression, ExecExpandExpression, Expression, int, int, T> resolver) {
+      return this.GetFromTree(index, 0, null, resolver);
+    }
+
+    private T GetFromTree<T>(int index, int parentIndex, ExecExpandExpression parent, Func<ExecExpandExpression, ExecExpandExpression, Expression, int, int, T> resolver) {
+      if (index == 0) return resolver(parent, parent, this, 0, parentIndex);
+
+      this.BuildIndexIfNecessary();
+
+      var min = this.State.Length - 1;
+      var max = 0;
+      var mid = (min + max) / 2;
+
+      while ((max <= min) && (this.treeIndex[mid] != index)) {
+        if (this.treeIndex[mid] > index) max = mid + 1;
+        else min = mid - 1;
+
+        mid = (min + max) / 2;
+      }
+
+      return this.treeIndex[mid] == index
+        ? resolver(parent, this, this.State[mid], mid, parentIndex)
+        : (this.State[mid + 1] as ExecExpandExpression).GetFromTree(index - this.treeIndex[mid + 1], mid + 1, this, resolver);
+    }
+
+    private void BuildIndexIfNecessary() {
+      if (this.treeIndex != null) return;
+
+      this.BuildIndex();
+    }
+
+    private void BuildIndex() {
+      this.treeIndex = new int[this.State.Length];
+
+      var next = 1;
+
+      for (var i = this.State.Length - 1; i >= 0; i--) {
+        var subExpression = this.State[i];
+
+        this.treeIndex[i] = next;
+
+        if (subExpression.GetType() == typeof(ExecExpandExpression)) {
+          next += (subExpression as ExecExpandExpression).TotalCount;
+        } else {
+          next++;
         }
-
-        /// <summary>
-        /// Use this method to ensure the amount of expressions is not higher than the limit configured (Configuration.MaxPointsInProgram)
-        /// </summary>
-        /// <param name="expressions"></param>
-        /// <param name="config"></param>
-        /// <returns>Returns an ExpandExpression if maxPoints smaller or equal to Configuration.MaxProgramPoints and Noop otherwise</returns>
-        public static Expression TryCreate(Expression[] expressions, Configuration config)
-        {
-            if (config.MaxPointsInProgram > expressions.Length)
-            {
-                return new ExecExpandExpression(expressions);
-            }
-            else
-            {
-                return new CodeNoopExpression();
-            }
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            var sb = new StringBuilder();
-
-            sb.Append(prefix);
-
-            for (var i = Expressions.Length - 1; i >= 0; i--)
-            {
-                sb.Append(Expressions[i].ToString() + delimiter);
-            }
-
-            sb.Append(postfix);
-
-            return sb.ToString();
-        }
-
-        protected override int InitId()
-        {
-            unchecked
-            {
-                var hash = 19;
-                foreach (var e in Expressions)
-                {
-                    hash *= 31 + e.GetHashCode();
-                }
-
-                return hash;
-            }
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new ExecExpandExpression(this, cloner);
-        }
-
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
-
-        public override bool Equals(object obj)
-        {
-            if (obj == null || obj.GetType() != typeof(ExecExpandExpression))
-            {
-                return false;
-            }
-
-            if (ReferenceEquals(this, obj))
-            {
-                return true;
-            }
-
-            var other = obj as ExecExpandExpression;
-
-            return Expressions.SequenceEqual(other.Expressions);
-        }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            interpreter.ExecStack.Push(Expressions);
-        }
-
-        /// <summary>
-        /// Returns the amount of elements in the whole tree
-        /// </summary>
-        /// <returns></returns>
-        public int TotalCount
-        {
-            get
-            {
-                BuildIndexIfNecessary();
-
-                return treeIndex.Count;
-            }
-        }
-
-        /// <summary>
-        /// Returns the element with the given index whereby the tree is indexed in depth first manner
-        /// </summary>
-        /// <param name="index">The index of the required element</param>
-        /// <returns>The required element</returns>
-        public Expression GetFromTree(int index)
-        {
-            BuildIndexIfNecessary();
-
-            return treeIndex[index];
-        }
-
-        private void BuildIndexIfNecessary()
-        {
-            if (treeIndex != null)
-                return;
-
-            treeIndex = new List<Expression>(Expressions.Length) { this };
-
-            for (var i = Expressions.Length - 1; i >= 0; i--)
-            {
-                var subExpression = Expressions[i];
-
-                if (subExpression.GetType() == typeof(ExecExpandExpression))
-                {
-                    var expand = subExpression as ExecExpandExpression;
-
-                    expand.BuildIndexIfNecessary();
-                    treeIndex.AddRange(expand.treeIndex);
-                }
-                else
-                {
-                    treeIndex.Add(subExpression);
-                }
-
-            }
-        }
-    }
-
-    /// <summary>
-    /// If the top item of the BOOLEAN stack is TRUE then this removes the second item on the EXEC stack, leaving the first item to be
-    /// executed. If it is false then it removes the first item, leaving the second to be executed. This is similar to CODE.IF except
-    /// that it operates on the EXEC stack. This acts as a NOOP unless there are at least two items on the EXEC stack and one item on
-    /// the BOOLEAN stack.
-    /// </summary>
-    public class ExecIfExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "EXEC.IF"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.BooleanStack.Count == 0 ||
-                interpreter.ExecStack.Count < 2)
-                return;
-
-            var condition = interpreter.BooleanStack.Pop();
-
-            if (condition)
-                interpreter.ExecStack.RemoveAt(interpreter.ExecStack.Count - 2);
-            else
-                interpreter.ExecStack.RemoveTop();
-        }
-    }
-
-    /// <summary>
-    /// The Push implementation of the "Y combinator". Inserts beneath the top item of the EXEC stack a new item of the form
-    /// "( EXEC.Y <TopItem> )".
-    /// </summary>
-    public class ExecYExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "EXEC.Y"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            // not enough arguments on stack
-            if (interpreter.ExecStack.Count == 0)
-                return;
-
-            var expandExpression = ExecExpandExpression.TryCreate(new[]
-            {
-                interpreter.ExecStack.Top,
-                new ExecYExpression()
-            }, interpreter.Configuration);
-
-            interpreter.ExecStack.Insert(interpreter.ExecStack.Count - 1, expandExpression);
-        }
-    }
-
-    /// <summary>
-    /// The Push implementation of the "K combinator". Removes the second item on the EXEC stack.
-    /// </summary>
-    public class ExecKExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "EXEC.K"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.ExecStack.Count < 2)
-                return;
-
-            var top = interpreter.ExecStack.Pop();
-            interpreter.ExecStack.SetTop(top);
-        }
-    }
-
-    /// <summary>
-    /// The Push implementation of the "S combinator". Pops 3 items from the EXEC stack, which we will call A, B, and C
-    /// (with A being the first one popped). Then pushes a list containing B and C back onto the EXEC stack, followed by
-    /// another instance of C, followed by another instance of A.
-    /// </summary>
-    public class ExecSExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "EXEC.S"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.ExecStack.Count < 3)
-                return;
-
-            var expressions = interpreter.ExecStack.Pop(2);
-            var a = expressions[1];
-            var b = expressions[0];
-            var c = interpreter.ExecStack.Top;
-
-            interpreter.ExecStack.SetTop(ExecExpandExpression.TryCreate(new[] { c, b }, interpreter.Configuration));
-            interpreter.ExecStack.Push(c, a);
-        }
-    }
+      }
+    }
+  }
+
+  /// <summary>
+  /// If the top item of the BOOLEAN stack is TRUE then this removes the second item on the EXEC stack, leaving the first
+  /// item to be executed. If it is false then it removes the first item, leaving the second to be executed. This is similar to
+  /// CODE.IF except that it operates on the EXEC stack. This acts as a NOOP unless there are at least two items on the EXEC stack and
+  /// one item on the BOOLEAN stack.
+  /// </summary>
+  public class ExecIfExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.IF";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if ((interpreter.BooleanStack.Count == 0) || (interpreter.ExecStack.Count < 2)) return;
+
+      var condition = interpreter.BooleanStack.Pop();
+
+      if (condition) interpreter.ExecStack.RemoveAt(interpreter.ExecStack.Count - 2);
+      else interpreter.ExecStack.RemoveTop();
+    }
+  }
+
+  /// <summary>
+  ///     Inserts beneath the top item of the EXEC stack a new item of the form
+  ///     "( EXEC.Y <TopItem> )".
+  /// </summary>
+  public class ExecYExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.Y";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      // not enough arguments on stack
+      if ((interpreter.ExecStack.Count == 0) || (interpreter.Configuration.MaxPointsInProgram < 2)) return;
+
+      var top = interpreter.ExecStack.Top;
+      var result = new ExecExpandExpression(new[] { top, new ExecYExpression() });
+
+      interpreter.ExecStack.Insert(interpreter.ExecStack.Count - 1, result);
+    }
+  }
+
+  /// <summary>
+  ///     Removes the second item on the EXEC stack.
+  /// </summary>
+  public class ExecKExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.K";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.ExecStack.Count < 2) return;
+
+      var top = interpreter.ExecStack.Pop();
+      interpreter.ExecStack.SetTop(top);
+    }
+  }
+
+  /// <summary>
+  ///     Pops 3 items from the EXEC stack, which we will call A, B, and C
+  ///     (with A being the first one popped). Then pushes a list containing B and C back onto the EXEC stack, followed by
+  ///     another instance of C, followed by another instance of A.
+  /// </summary>
+  public class ExecSExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "EXEC.S";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (interpreter.ExecStack.Count < 3) return;
+
+      var State = interpreter.ExecStack.Pop(2);
+      var a = State[1];
+      var b = State[0];
+      var c = interpreter.ExecStack.Top;
+
+      var newTop = new ExecExpandExpression(new[] { c, b });
+
+      interpreter.ExecStack.SetTop(newTop);
+      interpreter.ExecStack.Push(c, a);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/Expression.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/Expression.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/Expression.cs	(revision 14513)
@@ -1,70 +1,39 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class Expression : DeepCloneable
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  public abstract class Expression {
+    protected int id;
+    protected string stringRepresentation;
+
+    public string StringRepresentation
     {
-        private string stringRepresentation;
-        private int id;
+      get { return this.stringRepresentation ?? (this.stringRepresentation = this.InitStringRepresentation()); }
+    }
 
-        public Expression()
-        { }
+    public int Id
+    {
+      get
+      {
+        if (this.id == default(int))
+          this.id = this.InitId();
 
-        /// <summary>
-        /// Clone Constructor
-        /// </summary>
-        protected Expression(Expression origin, Cloner cloner)
-        {
-            stringRepresentation = origin.stringRepresentation;
-            id = origin.id;
-        }
+        return this.id;
+      }
+    }
 
-        public abstract void Eval(IInterpreter interpreter);
+    public abstract void Eval(IPushGpInterpreter interpreter);
 
-        protected abstract int InitId();
+    protected abstract int InitId();
 
-        protected abstract string InitStringRepresentation();
+    protected abstract string InitStringRepresentation();
 
-        public string StringRepresentation
-        {
-            get
-            {
-                if (stringRepresentation == null)
-                {
-                    stringRepresentation = InitStringRepresentation();
-                }
+    public override bool Equals(object obj) {
+      return (obj != null) && ((this.GetHashCode() == obj.GetHashCode()) || (this.GetType() == obj.GetType()));
+    }
 
-                return stringRepresentation;
-            }
-        }
-
-        public int Id
-        {
-            get
-            {
-                if (id == default(int))
-                {
-                    id = InitId();
-                }
-
-                return id;
-            }
-        }
-
-        public override bool Equals(object obj)
-        {
-            return obj != null && (GetHashCode() == obj.GetHashCode() || GetType() == obj.GetType());
-        }
-
-        public override string ToString()
-        {
-            return StringRepresentation;
-        }
-
-        public override int GetHashCode()
-        {
-            return Id;
-        }
+    public override int GetHashCode() {
+      return this.Id;
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExpressionTable.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExpressionTable.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ExpressionTable.cs	(revision 14513)
@@ -0,0 +1,143 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using System;
+  using System.Collections.Generic;
+  using System.Linq;
+
+  public static class ExpressionTable {
+    private static readonly Dictionary<string, Expression> statelessExpressionTable;
+
+    private static readonly Dictionary<string, Func<Expression>> statefullExpressionFactory;
+
+    public static int Count;
+
+    static ExpressionTable() {
+      statelessExpressionTable = GetStatelessExperssionTable(e => e.StringRepresentation);
+      statefullExpressionFactory = GetStatefullExpressionFactory(e => e.StringRepresentation);
+
+      Count = statelessExpressionTable.Count + statefullExpressionFactory.Count;
+    }
+
+    public static int StatelessCount
+    {
+      get
+      {
+        return statelessExpressionTable.Count;
+      }
+    }
+
+    public static int StatefullCount
+    {
+      get
+      {
+        return statefullExpressionFactory.Count;
+      }
+    }
+
+    private static Dictionary<string, Expression> GetStatelessExperssionTable(Func<Expression, string> keyFunc) {
+      var dictionary = new Dictionary<string, Expression>();
+      var expressionTypes = GetExpressionTypes(typeof(StatelessExpression));
+
+      foreach (var type in expressionTypes) {
+        var expression = Activator.CreateInstance(type) as Expression;
+        var key = keyFunc(expression);
+
+        dictionary.Add(key, expression);
+      }
+
+      return dictionary;
+    }
+
+    private static Dictionary<string, Func<Expression>> GetStatefullExpressionFactory(Func<Expression, string> keyFunc) {
+      var dictionary = new Dictionary<string, Func<Expression>>();
+      var statefullExpressionType = typeof(StatefullExpression<>);
+      var expressionTypes = GetExpressionTypes(statefullExpressionType);
+
+      foreach (var type in expressionTypes) {
+        // Make a NewExpression that calls the ctor
+        var newExp = System.Linq.Expressions.Expression.New(type);
+
+        // Create a lambda with the New expression as body
+        var creator = System.Linq.Expressions.Expression.Lambda<Func<Expression>>(newExp).Compile();
+        var expression = creator();
+        var key = keyFunc(expression);
+
+        dictionary.Add(key, creator);
+      }
+
+      return dictionary;
+    }
+
+    private static bool IsSubclassOf(Type type, Type baseType) {
+      if (type == null || baseType == null || type == baseType)
+        return false;
+
+      if (baseType.IsGenericType == false) {
+        if (type.IsGenericType == false)
+          return type.IsSubclassOf(baseType);
+      } else {
+        baseType = baseType.GetGenericTypeDefinition();
+      }
+
+      type = type.BaseType;
+      var objectType = typeof(object);
+      while (type != objectType && type != null) {
+        var curentType = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
+        if (curentType == baseType)
+          return true;
+
+        type = type.BaseType;
+      }
+
+      return false;
+    }
+
+    private static IEnumerable<Type> GetExpressionTypes(Type baseType) {
+      return from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
+             from assemblyType in domainAssembly.GetTypes()
+             where !assemblyType.IsAbstract &&
+                   IsSubclassOf(assemblyType, baseType) &&
+                   assemblyType.GetConstructor(Type.EmptyTypes) != null
+             select assemblyType;
+    }
+
+    public static Expression GetExpression(int index) {
+      // TODO: build lookup table for index to determine the key for the dictionary (get rid of ElementAt, is it slow?)
+      return index < StatelessCount
+               ? statelessExpressionTable.ElementAt(index).Value
+               : statefullExpressionFactory.ElementAt(index - StatelessCount).Value();
+    }
+
+    public static Expression GetExpression(string symbol) {
+      Expression expression;
+      if (TryGetStatelessExpression(symbol, out expression) || TryGetStatefullExpression(symbol, out expression)) return expression;
+
+      return null;
+    }
+
+    public static Expression GetStatelessExpression(string symbol) {
+      Expression expression;
+      if (statelessExpressionTable.TryGetValue(symbol, out expression)) return expression;
+      throw new NotSupportedException("Expression not supported: " + symbol);
+    }
+
+    public static bool TryGetStatelessExpression(string name, out Expression expression) {
+      return statelessExpressionTable.TryGetValue(name, out expression);
+    }
+
+    public static Expression GetStatefullExpression(string symbol) {
+      Func<Expression> creator;
+      if (statefullExpressionFactory.TryGetValue(symbol, out creator)) return creator();
+      throw new NotSupportedException("Expression not supported: " + symbol);
+    }
+
+    public static bool TryGetStatefullExpression(string name, out Expression expression) {
+      Func<Expression> creator;
+      if (statefullExpressionFactory.TryGetValue(name, out creator)) {
+        expression = creator();
+        return true;
+      }
+      expression = default(Expression);
+      return false;
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FloatExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FloatExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FloatExpressions.cs	(revision 14513)
@@ -1,203 +1,228 @@
-﻿using System;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-
-namespace HeuristicLab.Algorithms.PushGP.Expressions
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
 {
-    /// <summary>
-    /// Pushes the sum of the top two items.
-    /// </summary>
-    public class FloatAddExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.+"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => values[0] + values[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the difference of the top two items; that is, the second item minus the top item.
-    /// </summary>
-    public class FloatSubtractExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.-"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => values[0] - values[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the product of the top two items.
-    /// </summary>
-    public class FloatMultiplyExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.*"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => values[0] * values[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the quotient of the top two items; that is, the second item divided by the top item.
-    /// If the top item is zero this acts as a NOOP.
-    /// </summary>
-    public class FloatDivideExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT./"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => values[0] / values[1], 0);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the second stack item modulo the top stack item. If the top item is zero this acts as a NOOP.
-    /// The modulus is computed as the remainder of the quotient, where the quotient has first been truncated toward negative infinity.
-    /// (This is taken from the definition for the generic MOD function in Common Lisp, which is described
-    /// for example at http://www.lispworks.com/reference/HyperSpec/Body/f_mod_r.htm.)
-    /// </summary>
-    public class FloatModuloExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.%"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => values[0] % values[1], 0);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the minimum of the top two items.
-    /// </summary>
-    public class FloatMinExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.MIN"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => Math.Min(values[0], values[1]));
-        }
-    }
-
-    /// <summary>
-    /// Pushes the maximum of the top two items.
-    /// </summary>
-    public class FloatMaxExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.MAX"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, 2, values => Math.Max(values[0], values[1]));
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the second item is less than the top item, or FALSE otherwise.
-    /// </summary>
-    public class FloatSmallerThanExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.<"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.FloatStack,
-                interpreter.BooleanStack,
-                2,
-                values => values[0] < values[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the second item is greater than the top item, or FALSE otherwise.
-    /// </summary>
-    public class FloatGreaterThanExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.>"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.FloatStack,
-                interpreter.BooleanStack,
-                2,
-                values => values[0] > values[1]);
-        }
-    }
-
-    /// <summary>
-    /// Pushes the sine of the top item.
-    /// </summary>
-    public class FloatSineExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.SIN"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.FloatStack,
-                1,
-                values => Math.Sin(values[0]));
-        }
-    }
-
-    /// <summary>
-    /// Pushes the cosine of the top item.
-    /// </summary>
-    public class FloatCosineExpression : PushResultExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.COS"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.FloatStack,
-                1,
-                values => Math.Cos(values[0]));
-        }
-    }
-
-    /// <summary>
-    /// Pushes 1 if the top BOOLEAN is TRUE, or 0 if the top BOOLEAN is FALSE.
-    /// </summary>
-    public class FloatFromBooleanExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.FROMBOOLEAN"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.BooleanStack.Count == 0)
-                return;
-
-            var condition = interpreter.BooleanStack.Pop();
-            var value = condition ? 1 : 0;
-
-            interpreter.FloatStack.Push(value);
-        }
-    }
-
-    /// <summary>
-    /// Pushes a floating point version of the top INTEGER.
-    /// </summary>
-    public class FloatFromIntegerExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.FROMINTEGER"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0)
-                return;
-
-            var value = (double)interpreter.IntegerStack.Pop();
-
-            interpreter.FloatStack.Push(value);
-        }
-    }
+  using System;
+
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  /// <summary>
+  ///     Pushes the sum of the top two items.
+  /// </summary>
+  public class FloatAddExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.+";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => values[0] + values[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the difference of the top two items; that is, the second item minus the top item.
+  /// </summary>
+  public class FloatSubtractExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.-";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => values[0] - values[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the product of the top two items.
+  /// </summary>
+  public class FloatMultiplyExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.*";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => values[0] * values[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the quotient of the top two items; that is, the second item divided by the top item.
+  ///     If the top item is zero this acts as a NOOP.
+  /// </summary>
+  public class FloatDivideExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT./";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => values[0] / values[1], 0);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the second stack item modulo the top stack item. If the top item is zero this acts as a NOOP.
+  ///     The modulus is computed as the remainder of the quotient, where the quotient has first been truncated toward
+  ///     negative infinity.
+  ///     (This is taken from the definition for the generic MOD function in Common Lisp, which is described
+  ///     for example at http://www.lispworks.com/reference/HyperSpec/Body/f_mod_r.htm.)
+  /// </summary>
+  public class FloatModuloExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.%";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => values[0] % values[1], 0);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the minimum of the top two items.
+  /// </summary>
+  public class FloatMinExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.MIN";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => Math.Min(values[0], values[1]));
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the maximum of the top two items.
+  /// </summary>
+  public class FloatMaxExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.MAX";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 2, values => Math.Max(values[0], values[1]));
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the second item is less than the top item, or FALSE otherwise.
+  /// </summary>
+  public class FloatSmallerThanExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.<";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, interpreter.BooleanStack, 2, values => values[0] < values[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the second item is greater than the top item, or FALSE otherwise.
+  /// </summary>
+  public class FloatGreaterThanExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.>";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, interpreter.BooleanStack, 2, values => values[0] > values[1]);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the sine of the top item.
+  /// </summary>
+  public class FloatSineExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.SIN";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 1, values => Math.Sin(values[0]));
+    }
+  }
+
+  /// <summary>
+  ///     Pushes the cosine of the top item.
+  /// </summary>
+  public class FloatCosineExpression : PushResultExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.COS";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.FloatStack, 1, values => Math.Cos(values[0]));
+    }
+  }
+
+  /// <summary>
+  ///     Pushes 1 if the top BOOLEAN is TRUE, or 0 if the top BOOLEAN is FALSE.
+  /// </summary>
+  public class FloatFromBooleanExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.FROMBOOLEAN";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      if (interpreter.BooleanStack.Count == 0) return;
+
+      var condition = interpreter.BooleanStack.Pop();
+      var value = condition ? 1 : 0;
+
+      interpreter.FloatStack.Push(value);
+    }
+  }
+
+  /// <summary>
+  ///     Pushes a floating point version of the top INTEGER.
+  /// </summary>
+  public class FloatFromIntegerExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.FROMINTEGER";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      if (interpreter.IntegerStack.Count == 0) return;
+
+      var value = (double)interpreter.IntegerStack.Pop();
+
+      interpreter.FloatStack.Push(value);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FlushExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FlushExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/FlushExpressions.cs	(revision 14513)
@@ -1,77 +1,95 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Empties the given stack.
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class FlushExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Empties the given stack.
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class FlushExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack)
     {
-        public void Eval(IStack<T> stack)
-        {
-            stack.Clear();
-        }
+      stack.Clear();
+    }
+  }
+
+  public class IntegerFlushExpression : FlushExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.FLUSH";
     }
 
-    public class IntegerFlushExpression : FlushExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.FLUSH"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+  public class FloatFlushExpression : FlushExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.FLUSH";
     }
 
-    public class FloatFlushExpression : FlushExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.FLUSH"; }
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class BooleanFlushExpression : FlushExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.FLUSH";
     }
 
-    public class BooleanFlushExpression : FlushExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.FLUSH"; }
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+  public class NameFlushExpression : FlushExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.FLUSH";
     }
 
-    public class NameFlushExpression : FlushExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.FLUSH"; }
+      this.Eval(interpreter.NameStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
+  public class ExecFlushExpression : FlushExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.FLUSH";
     }
 
-    public class ExecFlushExpression : FlushExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.FLUSH"; }
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+  public class CodeFlushExpression : FlushExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.FLUSH";
     }
 
-    public class CodeFlushExpression : FlushExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.FLUSH"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack);
-        }
+      this.Eval(interpreter.CodeStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/IntegerExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/IntegerExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/IntegerExpressions.cs	(revision 14513)
@@ -1,171 +1,197 @@
-﻿using System;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using System;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes the sum of the top two items.
-    /// </summary>
-    public class IntegerAddExpression : PushResultExpression<long>
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  /// <summary>
+  ///     Pushes the sum of the top two items.
+  /// </summary>
+  public class IntegerAddExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
     {
-        protected override string InitStringRepresentation() { return "INTEGER.+"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => values[0] + values[1]);
-        }
+      return "INTEGER.+";
     }
 
-    /// <summary>
-    /// Pushes the difference of the top two items; that is, the second item minus the top item.
-    /// </summary>
-    public class IntegerSubtractExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.-"; }
+      this.Eval(interpreter.IntegerStack, 2, values => values[0] + values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => values[0] - values[1]);
-        }
+  /// <summary>
+  ///     Pushes the difference of the top two items; that is, the second item minus the top item.
+  /// </summary>
+  public class IntegerSubtractExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.-";
     }
 
-    /// <summary>
-    /// Pushes the product of the top two items.
-    /// </summary>
-    public class IntegerMultiplyExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.*"; }
+      this.Eval(interpreter.IntegerStack, 2, values => values[0] - values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => values[0] * values[1]);
-        }
+  /// <summary>
+  ///     Pushes the product of the top two items.
+  /// </summary>
+  public class IntegerMultiplyExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.*";
     }
 
-    /// <summary>
-    /// Pushes the quotient of the top two items; that is, the second item divided by the top item.
-    /// If the top item is zero this acts as a NOOP.
-    /// </summary>
-    public class IntegerDivideExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER./"; }
+      this.Eval(interpreter.IntegerStack, 2, values => values[0] * values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => values[0] / values[1], 0);
-        }
+  /// <summary>
+  ///     Pushes the quotient of the top two items; that is, the second item divided by the top item.
+  ///     If the top item is zero this acts as a NOOP.
+  /// </summary>
+  public class IntegerDivideExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER./";
     }
 
-    /// <summary>
-    /// Pushes the second stack item modulo the top stack item. If the top item is zero this acts as a NOOP. The modulus is computed as the
-    /// remainder of the quotient, where the quotient has first been truncated toward negative infinity. (This is taken from the definition
-    /// for the generic MOD function in Common Lisp, which is described for example at
-    /// http://www.lispworks.com/reference/HyperSpec/Body/f_mod_r.htm.)
-    /// </summary>
-    public class IntegerModuloExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.%"; }
+      this.Eval(interpreter.IntegerStack, 2, values => values[0] / values[1], 0);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => values[0] % values[1], 0);
-        }
+  /// <summary>
+  ///     Pushes the second stack item modulo the top stack item. If the top item is zero this acts as a NOOP. The modulus is
+  ///     computed as the
+  ///     remainder of the quotient, where the quotient has first been truncated toward negative infinity. (This is taken
+  ///     from the definition
+  ///     for the generic MOD function in Common Lisp, which is described for example at
+  ///     http://www.lispworks.com/reference/HyperSpec/Body/f_mod_r.htm.)
+  /// </summary>
+  public class IntegerModuloExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.%";
     }
 
-    /// <summary>
-    /// Pushes the minimum of the top two items.
-    /// </summary>
-    public class IntegerMinExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.MIN"; }
+      this.Eval(interpreter.IntegerStack, 2, values => values[0] % values[1], 0);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => Math.Min(values[0], values[1]));
-        }
+  /// <summary>
+  ///     Pushes the minimum of the top two items.
+  /// </summary>
+  public class IntegerMinExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.MIN";
     }
 
-    /// <summary>
-    /// Pushes the maximum of the top two items.
-    /// </summary>
-    public class IntegerMaxExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.MAX"; }
+      this.Eval(interpreter.IntegerStack, 2, values => Math.Min(values[0], values[1]));
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, 2, values => Math.Max(values[0], values[1]));
-        }
+  /// <summary>
+  ///     Pushes the maximum of the top two items.
+  /// </summary>
+  public class IntegerMaxExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.MAX";
     }
 
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the second item is less than the top item, or FALSE otherwise.
-    /// </summary>
-    public class IntegerSmallerThanExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.<"; }
+      this.Eval(interpreter.IntegerStack, 2, values => Math.Max(values[0], values[1]));
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.IntegerStack,
-                interpreter.BooleanStack,
-                2,
-                values => values[0] < values[1]);
-        }
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the second item is less than the top item, or FALSE otherwise.
+  /// </summary>
+  public class IntegerSmallerThanExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.<";
     }
 
-    /// <summary>
-    /// Pushes TRUE onto the BOOLEAN stack if the second item is greater than the top item, or FALSE otherwise.
-    /// </summary>
-    public class IntegerGreaterThanExpression : PushResultExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.>"; }
+      this.Eval(interpreter.IntegerStack, interpreter.BooleanStack, 2, values => values[0] < values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(
-                interpreter.IntegerStack,
-                interpreter.BooleanStack,
-                2,
-                values => values[0] > values[1]);
-        }
+  /// <summary>
+  ///     Pushes TRUE onto the BOOLEAN stack if the second item is greater than the top item, or FALSE otherwise.
+  /// </summary>
+  public class IntegerGreaterThanExpression : PushResultExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.>";
     }
 
-    /// <summary>
-    /// Pushes 1 if the top BOOLEAN is TRUE, or 0 if the top BOOLEAN is FALSE.
-    /// </summary>
-    public class IntegerFromBooleanExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.FROMBOOLEAN"; }
+      this.Eval(interpreter.IntegerStack, interpreter.BooleanStack, 2, values => values[0] > values[1]);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.BooleanStack.Count == 0)
-                return;
-
-            var condition = interpreter.BooleanStack.Pop();
-            var value = condition ? 1 : 0;
-
-            interpreter.IntegerStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes 1 if the top BOOLEAN is TRUE, or 0 if the top BOOLEAN is FALSE.
+  /// </summary>
+  public class IntegerFromBooleanExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.FROMBOOLEAN";
     }
 
-    /// <summary>
-    /// Pushes the result of truncating the top FLOAT.
-    /// </summary>
-    public class IntegerFromFloatExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.FROMFLOAT"; }
+      if (interpreter.BooleanStack.Count == 0) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.FloatStack.Count == 0)
-                return;
+      var condition = interpreter.BooleanStack.Pop();
+      var value = condition ? 1 : 0;
 
-            var value = (int)interpreter.FloatStack.Pop();
+      interpreter.IntegerStack.Push(value);
+    }
+  }
 
-            interpreter.IntegerStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes the result of truncating the top FLOAT.
+  /// </summary>
+  public class IntegerFromFloatExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.FROMFLOAT";
     }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      if (interpreter.FloatStack.Count == 0) return;
+
+      var value = (int)interpreter.FloatStack.Pop();
+
+      interpreter.IntegerStack.Push(value);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/LoopExpression.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/LoopExpression.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/LoopExpression.cs	(revision 14513)
@@ -1,121 +1,93 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class LoopExpression : StatefullExpression
-    {
-        protected long destinationIndex;
-        protected long currentIndex;
-        protected long incrementor;
-        protected Expression body;
+  public class LoopState {
+    public Expression Body;
+    public long CurrentIndex;
+    public long DestinationIndex;
+    public long Incrementor;
+  }
 
-        public LoopExpression()
-        { }
+  public abstract class LoopExpression : StatefullExpression<LoopState> {
+    protected LoopExpression() : base(new LoopState()) { }
 
-        /// <summary>
-        /// Clone constructor
-        /// </summary>
-        protected LoopExpression(LoopExpression origin, Cloner cloner) : base(origin, cloner)
-        {
-            destinationIndex = origin.destinationIndex;
-            currentIndex = origin.currentIndex;
-            incrementor = origin.incrementor;
-            body = origin.body;
-        }
+    protected void Eval(IPushGpInterpreter interpreter, IStack<Expression> sourceStack, bool pushCurrentIndex = false) {
+      // if not initialized
+      if (this.State.Body == null) {
+        if (this.HasInsufficientArguments(interpreter, sourceStack)) return;
 
-        protected void Eval(IInterpreter interpreter, IStack<Expression> sourceStack, bool pushCurrentIndex = false)
-        {
-            // if not initialized
-            if (body == null)
-            {
-                if (HasInsufficientArguments(interpreter, sourceStack))
-                {
-                    return;
-                }
+        this.InitState(interpreter, sourceStack);
 
-                InitState(interpreter, sourceStack);
+        interpreter.ExecStack.Push(this, this.State.Body);
 
-                interpreter.ExecStack.Push(this, body);
+        return;
+      }
 
-                return;
-            }
+      // if loop end reached
+      if (this.State.DestinationIndex == this.State.CurrentIndex) {
+        this.PushLastIteration(interpreter);
+        this.Clear();
 
-            // if loop end reached
-            if (destinationIndex == currentIndex)
-            {
-                PushLastIteration(interpreter);
-                Clear();
+        return;
+      }
 
-                return;
-            }
+      this.PushIteration(interpreter);
+      this.State.CurrentIndex += this.State.Incrementor;
+    }
 
-            PushIteration(interpreter);
-            currentIndex += incrementor;
-        }
+    protected virtual void Clear() {
+      this.State.Body = null;
+    }
 
-        protected virtual void Clear()
-        {
-            body = null;
-        }
+    protected virtual void PushIteration(IPushGpInterpreter interpreter) {
+      interpreter.IntegerStack.Push(this.State.CurrentIndex);
+      interpreter.ExecStack.Push(this, this.State.Body);
+    }
 
-        protected virtual void PushIteration(IInterpreter interpreter)
-        {
-            interpreter.IntegerStack.Push(currentIndex);
-            interpreter.ExecStack.Push(this, body);
-        }
+    protected virtual void PushLastIteration(IPushGpInterpreter interpreter) {
+      interpreter.IntegerStack.Push(this.State.CurrentIndex);
+      interpreter.ExecStack.Push(this.State.Body);
+    }
 
-        protected virtual void PushLastIteration(IInterpreter interpreter)
-        {
-            interpreter.IntegerStack.Push(currentIndex);
-            interpreter.ExecStack.Push(body);
-        }
+    public override bool Equals(object obj) {
+      if (!base.Equals(obj)) return false;
 
-        public override bool Equals(object obj)
-        {
-            if (!base.Equals(obj))
-            {
-                return false;
-            }
+      var other = obj as LoopExpression;
 
-            var other = obj as LoopExpression;
+      var isBodyEqual = ((this.State.Body == null) && (other.State.Body == null))
+                        || (this.State.Body != null && this.State.Body.Equals(other.State.Body));
 
-            var isBodyEqual =
-                (body == null && other.body == null) ||
-                (body != null && other.body != null && body.Equals(other.body));
+      return isBodyEqual && (this.State.CurrentIndex == other.State.CurrentIndex)
+             && (this.State.DestinationIndex == other.State.DestinationIndex) && (this.State.Incrementor == other.State.Incrementor);
+    }
 
-            return isBodyEqual &&
-                currentIndex == other.currentIndex &&
-                destinationIndex == other.destinationIndex &&
-                incrementor == other.incrementor;
-        }
+    public override string ToString() {
+      return this.StringRepresentation;
+    }
 
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
+    public override int GetHashCode() {
+      return base.GetHashCode();
+    }
 
-        protected override int InitId()
-        {
-            unchecked
-            {
-                var hash = 19;
+    protected override int InitId() {
+      unchecked {
+        var hash = 19;
 
-                if (body != null)
-                {
-                    hash *= 31 + body.GetHashCode();
-                }
+        hash = hash * 31 + this.GetType().GetHashCode();
 
-                hash *= 31 + currentIndex.GetHashCode();
-                hash *= 31 + destinationIndex.GetHashCode();
-                hash *= 31 + incrementor.GetHashCode();
+        if ((this.State.Body != null) && (this.State.Body != this)) hash = hash * 31 + this.State.Body.GetHashCode();
 
-                return hash;
-            }
-        }
+        hash = hash * 31 + this.State.CurrentIndex.GetHashCode();
+        hash = hash * 31 + this.State.DestinationIndex.GetHashCode();
+        hash = hash * 31 + this.State.Incrementor.GetHashCode();
 
-        protected abstract bool HasInsufficientArguments(IInterpreter interpreter, IStack<Expression> sourceStack);
-        protected abstract void InitState(IInterpreter interpreter, IStack<Expression> sourceStack);
+        return hash;
+      }
     }
+
+    protected abstract bool HasInsufficientArguments(IPushGpInterpreter interpreter, IStack<Expression> sourceStack);
+
+    protected abstract void InitState(IPushGpInterpreter interpreter, IStack<Expression> sourceStack);
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/NameExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/NameExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/NameExpressions.cs	(revision 14513)
@@ -1,112 +1,85 @@
-﻿using System;
-using System.Linq;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using System.Linq;
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public class NameDefineXExecExpression : StatefullExpression
-    {
-        private readonly string name;
-        public NameDefineXExecExpression(string name)
-        {
-            this.name = name;
-        }
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Core;
 
-        public NameDefineXExecExpression(NameDefineXExecExpression origin, Cloner cloner) : base(origin, cloner)
-        {
-            name = origin.name;
-        }
+  public class NameDefineXExecExpression : StatefullExpression<string> {
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Expression expression;
-            if (!interpreter.IsNameQuoteFlagSet &&
-                interpreter.CustomExpressions.TryGetValue(name, out expression))
-            {
-                interpreter.ExecStack.Push(expression);
-            }
-            else
-            {
-                interpreter.NameStack.Push(name);
-                interpreter.IsNameQuoteFlagSet = false;
-            }
-        }
+    public NameDefineXExecExpression(string state) : base(state) { }
 
-        public override bool Equals(object obj)
-        {
-            if (!base.Equals(obj))
-            {
-                return false;
-            }
-
-            var other = obj as NameDefineXExecExpression;
-
-            return name.Equals(other.name);
-        }
-
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
-
-        protected override string InitStringRepresentation()
-        {
-            return name;
-        }
-
-        protected override int InitId()
-        {
-            return name.GetHashCode();
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            throw new NotImplementedException();
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      Expression expression;
+      if (!interpreter.IsNameQuoteFlagSet && interpreter.CustomExpressions.TryGetValue(this.State, out expression)) {
+        interpreter.ExecStack.Push(expression);
+      } else {
+        interpreter.NameStack.Push(this.State);
+        interpreter.IsNameQuoteFlagSet = false;
+      }
     }
 
-    /// <summary>
-    /// Sets a flag indicating that the next name encountered will be pushed onto the NAME stack (and not have its associated value
-    /// pushed onto the EXEC stack), regardless of whether or not it has a definition. Upon encountering such a name and pushing it
-    /// onto the NAME stack the flag will be cleared (whether or not the pushed name had a definition).
-    /// </summary>
-    public class NameQuoteExpression : StatelessExpression
-    {
-        protected override string InitStringRepresentation()
-        {
-            return "NAME.QUOTE";
-        }
+    public override bool Equals(object obj) {
+      if (!base.Equals(obj)) return false;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            interpreter.IsNameQuoteFlagSet = true;
-        }
+      var other = obj as NameDefineXExecExpression;
+
+      return this.State.Equals(other.State);
     }
 
-    /// <summary>
-    /// Pushes a randomly selected NAME that already has a definition.
-    /// </summary>
-    public class NameRandBoundNameExpression : StatelessExpression
-    {
-        private static IRandom rand = new FastRandom();
+    public override int GetHashCode() {
+      return base.GetHashCode();
+    }
 
-        protected override string InitStringRepresentation()
-        {
-            return "NAME.RANDBOUNDNAME";
-        }
+    protected override string InitStringRepresentation() {
+      return this.State;
+    }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (!interpreter.CustomExpressions.Any())
-                return;
+    protected override int InitId() {
+      var hash = 19;
 
-            var index = rand.Next(0, interpreter.CustomExpressions.Keys.Count - 1);
-            var name = interpreter.CustomExpressions.Keys.ElementAt(index);
+      hash = hash * 31 + this.GetType().GetHashCode();
+      hash = hash * 31 + this.State.GetHashCode();
 
-            interpreter.NameStack.Push(name);
-        }
+      return hash;
     }
+  }
+
+  /// <summary>
+  ///     Sets a flag indicating that the next State encountered will be pushed onto the NAME stack (and not have its
+  ///     associated value
+  ///     pushed onto the EXEC stack), regardless of whether or not it has a definition. Upon encountering such a State and
+  ///     pushing it
+  ///     onto the NAME stack the flag will be cleared (whether or not the pushed State had a definition).
+  /// </summary>
+  public class NameQuoteExpression : StatelessExpression {
+    protected override string InitStringRepresentation() {
+      return "NAME.QUOTE";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      interpreter.IsNameQuoteFlagSet = true;
+    }
+  }
+
+  /// <summary>
+  ///     Pushes a randomly selected NAME that already has a definition.
+  /// </summary>
+  public class NameRandBoundNameExpression : StatelessExpression {
+    private static readonly ThreadLocal<IRandom> Rand = RandomFactory.GetRandom();
+
+    protected override string InitStringRepresentation() {
+      return "NAME.RANDBOUNDNAME";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      if (!interpreter.CustomExpressions.Any()) return;
+
+      var index = Rand.Value.Next(0, interpreter.CustomExpressions.Keys.Count - 1);
+      var state = interpreter.CustomExpressions.Keys.ElementAt(index);
+
+      interpreter.NameStack.Push(state);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PopExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PopExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PopExpressions.cs	(revision 14513)
@@ -1,76 +1,93 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class PopExpression<T> : StatelessExpression
+  public abstract class PopExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack)
     {
-        public void Eval(IStack<T> stack)
-        {
-            if (stack.Count == 0)
-                return;
+      if (stack.Count == 0) return;
 
-            stack.Pop();
-        }
+      stack.Pop();
+    }
+  }
+
+  public class IntegerPopExpression : PopExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.POP";
     }
 
-    public class IntegerPopExpression : PopExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.POP"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+  public class FloatPopExpression : PopExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.POP";
     }
 
-    public class FloatPopExpression : PopExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.POP"; }
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class BooleanPopExpression : PopExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.POP";
     }
 
-    public class BooleanPopExpression : PopExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.POP"; }
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+  public class NamePopExpression : PopExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.POP";
     }
 
-    public class NamePopExpression : PopExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.POP"; }
+      this.Eval(interpreter.NameStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
+  public class ExecPopExpression : PopExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.POP";
     }
 
-    public class ExecPopExpression : PopExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.POP"; }
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+  public class CodePopExpression : PopExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.POP";
     }
 
-    public class CodePopExpression : PopExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.POP"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack);
-        }
+      this.Eval(interpreter.CodeStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushExpressions.cs	(revision 14513)
@@ -1,154 +1,103 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class PushExpression<T> : StatefullExpression
-    {
-        protected readonly T value;
+  public abstract class PushExpression<T> : StatefullExpression<T> {
 
-        public PushExpression(T value)
-        {
-            this.value = value;
-        }
+    protected PushExpression(T state) : base(state) { }
 
-        // copy constructor
-        public PushExpression(PushExpression<T> expression, Cloner cloner) : base(expression, cloner)
-        {
-            value = expression.value;
-        }
+    protected override int InitId() {
+      var hash = 19;
 
-        protected override int InitId()
-        {
-            return this.value.GetHashCode();
-        }
+      hash = hash * 31 + this.GetType().GetHashCode();
+      hash = hash * 31 + this.State.GetHashCode();
 
-        protected override string InitStringRepresentation()
-        {
-            return this.value.ToString();
-        }
-
-        protected void Eval(IStack<T> stack)
-        {
-            stack.Push(value);
-        }
-
-        public override bool Equals(object obj)
-        {
-            if (obj == null || !(obj is PushExpression<T>))
-            {
-                return false;
-            }
-
-            var other = obj as PushExpression<T>;
-
-            return value.Equals(value);
-        }
-
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
+      return hash;
     }
 
-    public class IntegerPushExpression : PushExpression<long>
-    {
-        public IntegerPushExpression(long value) : base(value)
-        { }
-
-        // copy constructor
-        public IntegerPushExpression(IntegerPushExpression expression, Cloner cloner) : base(expression, cloner)
-        { }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new IntegerPushExpression(this, cloner);
-        }
+    protected void Eval(IStack<T> stack) {
+      stack.Push(this.State);
     }
 
-    public class FloatPushExpression : PushExpression<double>
-    {
-        public FloatPushExpression(double value) : base(value)
-        { }
+    public override bool Equals(object obj) {
+      if (!(obj is PushExpression<T>)) return false;
+      var other = (PushExpression<T>)obj;
 
-        // copy constructor
-        public FloatPushExpression(FloatPushExpression expression, Cloner cloner) : base(expression, cloner)
-        { }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new FloatPushExpression(this, cloner);
-        }
+      return this.State.Equals(other.State);
     }
 
-    public class BooleanPushExpression : PushExpression<bool>
-    {
-        public BooleanPushExpression(bool value) : base(value)
-        { }
+    public override int GetHashCode() {
+      return base.GetHashCode();
+    }
+  }
 
-        // copy constructor
-        public BooleanPushExpression(BooleanPushExpression expression, Cloner cloner) : base(expression, cloner)
-        { }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new BooleanPushExpression(this, cloner);
-        }
+  public class IntegerPushExpression : PushExpression<long> {
+    public IntegerPushExpression(long state)
+      : base(state) {
     }
 
-    public class NamePushExpression : PushExpression<string>
-    {
-        public NamePushExpression(string value) : base(value)
-        { }
-
-        // copy constructor
-        public NamePushExpression(NamePushExpression expression, Cloner cloner) : base(expression, cloner)
-        { }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new NamePushExpression(this, cloner);
-        }
+    protected override string InitStringRepresentation() {
+      return "IntegerPush";
     }
 
-    public class ExecPushExpression : PushExpression<Expression>
-    {
-        public ExecPushExpression(Expression value) : base(value)
-        { }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        // copy constructor
-        public ExecPushExpression(ExecPushExpression expression, Cloner cloner) : base(expression, cloner)
-        { }
+  public class FloatPushExpression : PushExpression<double> {
+    public FloatPushExpression(double state)
+      : base(state) {
+    }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+    protected override string InitStringRepresentation() {
+      return "FloatPush";
+    }
 
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new ExecPushExpression(this, cloner);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.FloatStack);
     }
+  }
+
+  public class BooleanPushExpression : PushExpression<bool> {
+    public BooleanPushExpression(bool state)
+      : base(state) {
+    }
+
+    protected override string InitStringRepresentation() {
+      return "BooleanPush";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
+
+  public class NamePushExpression : PushExpression<string> {
+    public NamePushExpression(string state)
+      : base(state) {
+    }
+
+    protected override string InitStringRepresentation() {
+      return "NamePush";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.NameStack);
+    }
+  }
+
+  public class ExecPushExpression : PushExpression<Expression> {
+    public ExecPushExpression(Expression state)
+      : base(state) {
+    }
+
+    protected override string InitStringRepresentation() {
+      return "ExecPush";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs	(revision 14513)
@@ -1,35 +1,28 @@
-﻿using System;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using System;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class PushResultExpression<T> : StatelessExpression
-    {
-        protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc)
-        {
-            if (stack.Count < count)
-                return;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-            stack.PushResult(count, templateFunc);
-        }
+  public abstract class PushResultExpression<T> : StatelessExpression {
+    protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc) {
+      if (stack.Count < count) return;
 
-        protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue)
-        {
-            if (stack.Count < count || stack.Top.Equals(ignoreValue))
-                return;
+      stack.PushResult(count, templateFunc);
+    }
 
-            stack.PushResult(count, templateFunc);
-        }
+    protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue) {
+      if ((stack.Count < count) || stack.Top.Equals(ignoreValue)) return;
 
-        protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc)
-        {
-            if (stack.Count < count)
-                return;
+      stack.PushResult(count, templateFunc);
+    }
 
-            var items = stack.Pop(count);
-            var result = templateFunc(items);
+    protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc) {
+      if (stack.Count < count) return;
 
-            resultStack.Push(result);
-        }
+      var items = stack.Pop(count);
+      var result = templateFunc(items);
+
+      resultStack.Push(result);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RandExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RandExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RandExpressions.cs	(revision 14513)
@@ -1,87 +1,103 @@
-﻿using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Generators;
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes a random NAME.
-    /// </summary>
-    public class NameRandExpression : StatelessExpression
+  /// <summary>
+  ///     Pushes a random NAME.
+  /// </summary>
+  public class NameRandExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
     {
-        protected override string InitStringRepresentation() { return "NAME.RAND"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            var name = NameGenerator.RandomName();
-
-            interpreter.NameStack.Push(name);
-        }
+      return "NAME.RAND";
     }
 
-    /// <summary>
-    /// Pushes a random integer.
-    /// </summary>
-    public class IntegerRandExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.RAND"; }
+      var name = NameGenerator.RandomName();
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            var value = IntegerGenerator.RandomInteger(
-                interpreter.Configuration.MinRandomInteger,
-                interpreter.Configuration.MaxRandomInteger);
+      interpreter.NameStack.Push(name);
+    }
+  }
 
-            interpreter.IntegerStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes a random integer.
+  /// </summary>
+  public class IntegerRandExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.RAND";
     }
 
-    /// <summary>
-    /// Pushes a random float.
-    /// </summary>
-    public class FloatRandExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.RAND"; }
+      var value = IntegerGenerator.RandomInteger(
+        interpreter.Configuration.MinRandomInteger,
+        interpreter.Configuration.MaxRandomInteger);
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            var value = FloatGenerator.RandomFloat(
-                interpreter.Configuration.MinRandomFloat,
-                interpreter.Configuration.MaxRandomFloat);
+      interpreter.IntegerStack.Push(value);
+    }
+  }
 
-            interpreter.FloatStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes a random float.
+  /// </summary>
+  public class FloatRandExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.RAND";
     }
 
-    /// <summary>
-    /// Pushes a random boolean.
-    /// </summary>
-    public class BooleanRandExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.RAND"; }
+      var value = FloatGenerator.RandomFloat(
+        interpreter.Configuration.MinRandomFloat,
+        interpreter.Configuration.MaxRandomFloat);
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            var value = BooleanGenerator.RandomBoolean();
+      interpreter.FloatStack.Push(value);
+    }
+  }
 
-            interpreter.BooleanStack.Push(value);
-        }
+  /// <summary>
+  ///     Pushes a random boolean.
+  /// </summary>
+  public class BooleanRandExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.RAND";
     }
 
-    /// <summary>
-    /// Pushes random expressions onto the code stack.
-    /// </summary>
-    public class CodeRandExpression : StatelessExpression
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.RAND"; }
+      var value = BooleanGenerator.RandomBoolean();
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            if (interpreter.IntegerStack.Count == 0 ||
-                interpreter.IntegerStack.Top < 1)
-                return;
+      interpreter.BooleanStack.Push(value);
+    }
+  }
 
-            var size = (int)(interpreter.IntegerStack.Pop() % interpreter.Configuration.MaxPointsInRandomExpression);
-            var expression = interpreter.CodeGenerator.RandomCode(size);
-        }
+  /// <summary>
+  ///     Pushes random expressions onto the code stack.
+  /// </summary>
+  public class CodeRandExpression : StatelessExpression
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.RAND";
     }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      if ((interpreter.IntegerStack.Count == 0) || (interpreter.IntegerStack.Top < 1)) return;
+
+      var size = (int)(interpreter.IntegerStack.Pop() % interpreter.Configuration.MaxPointsInRandomExpression);
+
+      var expression = CodeGenerator.RandomProgram(size, interpreter.CustomExpressions);
+
+      interpreter.CodeStack.Push(expression);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RotateExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RotateExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RotateExpressions.cs	(revision 14513)
@@ -1,76 +1,93 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class RotateExpression<T> : StatelessExpression
+  public abstract class RotateExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack)
     {
-        public void Eval(IStack<T> stack)
-        {
-            if (stack.Count < 3)
-                return;
+      if (stack.Count < 3) return;
 
-            stack.Swap(3);
-        }
+      stack.Swap(3);
+    }
+  }
+
+  public class IntegerRotateExpression : RotateExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.ROT";
     }
 
-    public class IntegerRotateExpression : RotateExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.ROT"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+  public class FloatRotateExpression : RotateExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.ROT";
     }
 
-    public class FloatRotateExpression : RotateExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.ROT"; }
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class BooleanRotateExpression : RotateExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.ROT";
     }
 
-    public class BooleanRotateExpression : RotateExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.ROT"; }
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+  public class NameRotateExpression : RotateExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.ROT";
     }
 
-    public class NameRotateExpression : RotateExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.ROT"; }
+      this.Eval(interpreter.NameStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
+  public class ExecRotateExpression : RotateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.ROT";
     }
 
-    public class ExecRotateExpression : RotateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.ROT"; }
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+  public class CodeRotateExpression : RotateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.ROT";
     }
 
-    public class CodeRotateExpression : RotateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.ROT"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack);
-        }
+      this.Eval(interpreter.CodeStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ShoveExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ShoveExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/ShoveExpressions.cs	(revision 14513)
@@ -1,85 +1,98 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class ShoveExpression<T> : StatelessExpression
+  public abstract class ShoveExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack, IStack<long> integerStack, int count = 1)
     {
-        public void Eval(IStack<T> stack, IStack<long> integerStack, int count = 1)
-        {
-            if (integerStack.Count == 0)
-                return;
+      if (integerStack.Count == 0) return;
 
-            if (integerStack.Top > stack.Count - count ||
-                integerStack.Top < 0 ||
-                stack.Count < 2)
-                return;
+      if ((integerStack.Top > stack.Count - count) || (integerStack.Top < 0) || (stack.Count < 2)) return;
 
-            var index = integerStack.Pop();
-            var item = stack.Pop();
+      var index = (int)integerStack.Pop();
+      var item = stack.Pop();
 
-            // TODO: What if index > int.MaxValue ?
-            stack.Insert((int)index, item);
-        }
+      stack.Insert(index, item);
+    }
+  }
+
+  public class IntegerShoveExpression : ShoveExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.SHOVE";
     }
 
-    public class IntegerShoveExpression : ShoveExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.SHOVE"; }
+      this.Eval(interpreter.IntegerStack, interpreter.IntegerStack, 2);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, interpreter.IntegerStack, 2);
-        }
+  public class FloatShoveExpression : ShoveExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.SHOVE";
     }
 
-    public class FloatShoveExpression : ShoveExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.SHOVE"; }
+      this.Eval(interpreter.FloatStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, interpreter.IntegerStack);
-        }
+  public class BooleanShoveExpression : ShoveExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.SHOVE";
     }
 
-    public class BooleanShoveExpression : ShoveExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.SHOVE"; }
+      this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, interpreter.IntegerStack);
-        }
+  public class NameShoveExpression : ShoveExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.SHOVE";
     }
 
-    public class NameShoveExpression : ShoveExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.SHOVE"; }
+      this.Eval(interpreter.NameStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack, interpreter.IntegerStack);
-        }
+  public class ExecShoveExpression : ShoveExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.SHOVE";
     }
 
-    public class ExecShoveExpression : ShoveExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.SHOVE"; }
+      this.Eval(interpreter.ExecStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack, interpreter.IntegerStack);
-        }
+  public class CodeShoveExpression : ShoveExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.SHOVE";
     }
 
-    public class CodeShoveExpression : ShoveExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.SHOVE"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack, interpreter.IntegerStack);
-        }
+      this.Eval(interpreter.CodeStack, interpreter.IntegerStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StackdepthExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StackdepthExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StackdepthExpressions.cs	(revision 14513)
@@ -1,84 +1,78 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes the stack depth onto the INTEGER stack (thereby increasing it!).
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class StackdepthExpression<T> : StatelessExpression
-    {
-        public void Eval(IStack<T> stack, IStack<long> integerStack, bool incremental = false)
-        {
-            var count = stack.Count;
+  /// <summary>
+  ///     Pushes the stack depth onto the INTEGER stack (thereby increasing it!).
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class StackdepthExpression<T> : StatelessExpression {
+    public void Eval(IStack<T> stack, IStack<long> integerStack, bool incremental = false) {
+      var count = stack.Count;
 
-            if (incremental)
-            {
-                count += 1;
-            }
+      if (incremental) count += 1;
 
-            integerStack.Push(count);
-        }
+      integerStack.Push(count);
+    }
+  }
+
+  public class IntegerStackdepthExpression : StackdepthExpression<long> {
+    protected override string InitStringRepresentation() {
+      return "INTEGER.STACKDEPTH";
     }
 
-    public class IntegerStackdepthExpression : StackdepthExpression<long>
-    {
-        protected override string InitStringRepresentation() { return "INTEGER.STACKDEPTH"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.IntegerStack, interpreter.IntegerStack, true);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, interpreter.IntegerStack, true);
-        }
+  public class FloatStackdepthExpression : StackdepthExpression<double> {
+    protected override string InitStringRepresentation() {
+      return "FLOAT.STACKDEPTH";
     }
 
-    public class FloatStackdepthExpression : StackdepthExpression<double>
-    {
-        protected override string InitStringRepresentation() { return "FLOAT.STACKDEPTH"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.FloatStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, interpreter.IntegerStack);
-        }
+  public class BooleanStackdepthExpression : StackdepthExpression<bool> {
+    protected override string InitStringRepresentation() {
+      return "BOOLEAN.STACKDEPTH";
     }
 
-    public class BooleanStackdepthExpression : StackdepthExpression<bool>
-    {
-        protected override string InitStringRepresentation() { return "BOOLEAN.STACKDEPTH"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, interpreter.IntegerStack);
-        }
+  public class NameStackdepthExpression : StackdepthExpression<string> {
+    protected override string InitStringRepresentation() {
+      return "NAME.STACKDEPTH";
     }
 
-    public class NameStackdepthExpression : StackdepthExpression<string>
-    {
-        protected override string InitStringRepresentation() { return "NAME.STACKDEPTH"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.NameStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack, interpreter.IntegerStack);
-        }
+  public class ExecStackdepthExpression : StackdepthExpression<Expression> {
+    protected override string InitStringRepresentation() {
+      return "EXEC.STACKDEPTH";
     }
 
-    public class ExecStackdepthExpression : StackdepthExpression<Expression>
-    {
-        protected override string InitStringRepresentation() { return "EXEC.STACKDEPTH"; }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.ExecStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack, interpreter.IntegerStack);
-        }
+  public class CodeStackdepthExpression : StackdepthExpression<Expression> {
+    protected override string InitStringRepresentation() {
+      return "CODE.STACKDEPTH";
     }
 
-    public class CodeStackdepthExpression : StackdepthExpression<Expression>
-    {
-        protected override string InitStringRepresentation() { return "CODE.STACKDEPTH"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack, interpreter.IntegerStack);
-        }
+    public override void Eval(IPushGpInterpreter interpreter) {
+      this.Eval(interpreter.CodeStack, interpreter.IntegerStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatefullExpression.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatefullExpression.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatefullExpression.cs	(revision 14513)
@@ -1,13 +1,13 @@
-﻿using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  public abstract class StatefullExpression<T> : Expression {
+    protected T State { get; set; }
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class StatefullExpression : Expression
-    {
-        protected StatefullExpression()
-        { }
+    protected StatefullExpression(T state) {
+      this.State = state;
+    }
 
-        protected StatefullExpression(StatefullExpression origin, Cloner cloner) : base(origin, cloner)
-        { }
+    public override string ToString() {
+      return this.State.ToString();
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatelessExpression.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatelessExpression.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/StatelessExpression.cs	(revision 14513)
@@ -1,17 +1,11 @@
-﻿using HeuristicLab.Common;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions {
+  public abstract class StatelessExpression : Expression {
+    protected override int InitId() {
+      return this.GetType().GetHashCode();
+    }
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    public abstract class StatelessExpression : Expression
-    {
-        protected override int InitId()
-        {
-            return StringRepresentation.GetHashCode();
-        }
-
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return this;
-        }
+    public override string ToString() {
+      return this.StringRepresentation;
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/SwapExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/SwapExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/SwapExpressions.cs	(revision 14513)
@@ -1,80 +1,97 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Swaps the top two values.
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class SwapExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Swaps the top two values.
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class SwapExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack)
     {
-        public void Eval(IStack<T> stack)
-        {
-            if (stack.Count < 2)
-                return;
+      if (stack.Count < 2) return;
 
-            stack.Swap(2);
-        }
+      stack.Swap(2);
+    }
+  }
+
+  public class IntegerSwapExpression : SwapExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.SWAP";
     }
 
-    public class IntegerSwapExpression : SwapExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.SWAP"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack);
-        }
+  public class FloatSwapExpression : SwapExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.SWAP";
     }
 
-    public class FloatSwapExpression : SwapExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.SWAP"; }
+      this.Eval(interpreter.FloatStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack);
-        }
+  public class BooleanSwapExpression : SwapExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.SWAP";
     }
 
-    public class BooleanSwapExpression : SwapExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.SWAP"; }
+      this.Eval(interpreter.BooleanStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack);
-        }
+  public class NameSwapExpression : SwapExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.SWAP";
     }
 
-    public class NameSwapExpression : SwapExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.SWAP"; }
+      this.Eval(interpreter.NameStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack);
-        }
+  public class ExecSwapExpression : SwapExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.SWAP";
     }
 
-    public class ExecSwapExpression : SwapExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.SWAP"; }
+      this.Eval(interpreter.ExecStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack);
-        }
+  public class CodeSwapExpression : SwapExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.SWAP";
     }
 
-    public class CodeSwapExpression : SwapExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.SWAP"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack);
-        }
+      this.Eval(interpreter.CodeStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankDuplicateExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankDuplicateExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankDuplicateExpressions.cs	(revision 14513)
@@ -1,91 +1,127 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Pushes a copy of an indexed item "deep" in the stack onto the top of the stack, without removing the deep item.
-    /// The index is taken from the INTEGER stack, and the indexing is done after the index is removed.
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class YankDuplicateExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Pushes a copy of an indexed item "deep" in the stack onto the top of the stack, without removing the deep item.
+  ///     The index is taken from the INTEGER stack, and the indexing is done after the index is removed.
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class YankDuplicateExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack, IStack<long> integerStack)
     {
-        public void Eval(IStack<T> stack, IStack<long> integerStack, int count = 1)
-        {
-            if (integerStack.Count == 0)
-                return;
-
-            var index = integerStack.Top;
-
-            if (index > stack.Count - count ||
-                index < 0 ||
-                stack.Count < 2)
-                return;
-
-            integerStack.Pop();
-            var item = stack.ElementAt((int)index);
-
-            stack.Push(item);
-        }
+      T item;
+      if (this.TryGetItem(stack, integerStack, out item)) stack.Push(item);
     }
 
-    public class IntegerYankDuplicateExpression : YankDuplicateExpression<long>
+    public void Eval(IStack<Expression> stack, IStack<long> integerStack)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.YANKDUP"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, interpreter.IntegerStack, 2);
-        }
+      Expression item;
+      if (this.TryGetItem(stack, integerStack, out item)) stack.Push(item);
     }
 
-    public class FloatYankDuplicateExpression : YankDuplicateExpression<double>
+    public void Eval(IStack<long> integerStack)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.YANKDUP"; }
+      if ((integerStack.Count < 2) || (integerStack.Top > integerStack.Count - 2) || (integerStack.Top < 0)) return;
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, interpreter.IntegerStack);
-        }
+      var index = (int)integerStack.Pop();
+      var item = integerStack.ReverseElementAt(index);
+
+      integerStack.Push(item);
     }
 
-    public class BooleanYankDuplicateExpression : YankDuplicateExpression<bool>
+    private bool TryGetItem<E>(IStack<E> stack, IStack<long> integerStack, out E item)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.YANKDUP"; }
+      if ((integerStack.Count == 0) || (integerStack.Top >= stack.Count) || (integerStack.Top < 0) || (stack.Count < 2))
+      {
+        item = default(E);
+        return false;
+      }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, interpreter.IntegerStack);
-        }
+      var index = (int)integerStack.Pop();
+      item = stack.ReverseElementAt(index);
+
+      return true;
+    }
+  }
+
+  public class IntegerYankDuplicateExpression : YankDuplicateExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.YANKDUP";
     }
 
-    public class NameYankDuplicateExpression : YankDuplicateExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.YANKDUP"; }
+      this.Eval(interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack, interpreter.IntegerStack);
-        }
+  public class FloatYankDuplicateExpression : YankDuplicateExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.YANKDUP";
     }
 
-    public class ExecYankDuplicateExpression : YankDuplicateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.YANKDUP"; }
+      this.Eval(interpreter.FloatStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack, interpreter.IntegerStack);
-        }
+  public class BooleanYankDuplicateExpression : YankDuplicateExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.YANKDUP";
     }
 
-    public class CodeYankDuplicateExpression : YankDuplicateExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.YANKDUP"; }
+      this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack, interpreter.IntegerStack);
-        }
+  public class NameYankDuplicateExpression : YankDuplicateExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.YANKDUP";
     }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.NameStack, interpreter.IntegerStack);
+    }
+  }
+
+  public class ExecYankDuplicateExpression : YankDuplicateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.YANKDUP";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.ExecStack, interpreter.IntegerStack);
+    }
+  }
+
+  public class CodeYankDuplicateExpression : YankDuplicateExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.YANKDUP";
+    }
+
+    public override void Eval(IPushGpInterpreter interpreter)
+    {
+      this.Eval(interpreter.CodeStack, interpreter.IntegerStack);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankExpressions.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankExpressions.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/YankExpressions.cs	(revision 14513)
@@ -1,89 +1,103 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Algorithms.PushGP.Stack;
+﻿namespace HeuristicLab.Algorithms.PushGP.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Algorithms.PushGP.Expressions
-{
-    /// <summary>
-    /// Removes an indexed item from "deep" in the stack and pushes it on top of the stack.
-    /// The index is taken from the INTEGER stack, and the indexing is done after the index is removed.
-    /// </summary>
-    /// <typeparam name="T">Stacktype</typeparam>
-    public abstract class YankExpression<T> : StatelessExpression
+  /// <summary>
+  ///     Removes an indexed item from "deep" in the stack and pushes it on top of the stack.
+  ///     The index is taken from the INTEGER stack, and the indexing is done after the index is removed.
+  /// </summary>
+  /// <typeparam name="T">Stacktype</typeparam>
+  public abstract class YankExpression<T> : StatelessExpression
+  {
+    public void Eval(IStack<T> stack, IStack<long> integerStack, int count = 1)
     {
-        public void Eval(IStack<T> stack, IStack<long> integerStack, int count = 1)
-        {
-            if (integerStack.Count == 0)
-                return;
+      if (integerStack.Count == 0) return;
 
-            var index = integerStack.Top;
+      var index = integerStack.Top;
 
-            if (index > stack.Count - count ||
-                index < 0 ||
-                stack.Count < 2)
-                return;
+      if ((index > stack.Count - count) || (index < 0) || (stack.Count < 2)) return;
 
-            integerStack.Pop();
-            stack.Yank((int)index);
-        }
+      integerStack.Pop();
+      stack.Yank((int)index);
+    }
+  }
+
+  public class IntegerYankExpression : YankExpression<long>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "INTEGER.YANK";
     }
 
-    public class IntegerYankExpression : YankExpression<long>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "INTEGER.YANK"; }
+      this.Eval(interpreter.IntegerStack, interpreter.IntegerStack, 2);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.IntegerStack, interpreter.IntegerStack, 2);
-        }
+  public class FloatYankExpression : YankExpression<double>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "FLOAT.YANK";
     }
 
-    public class FloatYankExpression : YankExpression<double>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "FLOAT.YANK"; }
+      this.Eval(interpreter.FloatStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.FloatStack, interpreter.IntegerStack);
-        }
+  public class BooleanYankExpression : YankExpression<bool>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "BOOLEAN.YANK";
     }
 
-    public class BooleanYankExpression : YankExpression<bool>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "BOOLEAN.YANK"; }
+      this.Eval(interpreter.BooleanStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.BooleanStack, interpreter.IntegerStack);
-        }
+  public class NameYankExpression : YankExpression<string>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "NAME.YANK";
     }
 
-    public class NameYankExpression : YankExpression<string>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "NAME.YANK"; }
+      this.Eval(interpreter.NameStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.NameStack, interpreter.IntegerStack);
-        }
+  public class ExecYankExpression : YankExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "EXEC.YANK";
     }
 
-    public class ExecYankExpression : YankExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "EXEC.YANK"; }
+      this.Eval(interpreter.ExecStack, interpreter.IntegerStack);
+    }
+  }
 
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.ExecStack, interpreter.IntegerStack);
-        }
+  public class CodeYankExpression : YankExpression<Expression>
+  {
+    protected override string InitStringRepresentation()
+    {
+      return "CODE.YANK";
     }
 
-    public class CodeYankExpression : YankExpression<Expression>
+    public override void Eval(IPushGpInterpreter interpreter)
     {
-        protected override string InitStringRepresentation() { return "CODE.YANK"; }
-
-        public override void Eval(IInterpreter interpreter)
-        {
-            Eval(interpreter.CodeStack, interpreter.IntegerStack);
-        }
+      this.Eval(interpreter.CodeStack, interpreter.IntegerStack);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/BooleanGenerator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/BooleanGenerator.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/BooleanGenerator.cs	(revision 14513)
@@ -1,15 +1,14 @@
-﻿using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Generators {
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Generators
-{
-    public static class BooleanGenerator
-    {
-        private static IRandom rand = new FastRandom();
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Core;
 
-        public static bool RandomBoolean()
-        {
-            return rand.NextDouble() > 0.5 ? true : false;
-        }
+  public static class BooleanGenerator {
+    private static readonly ThreadLocal<IRandom> rand = RandomFactory.GetRandom();
+
+    public static bool RandomBoolean() {
+      return rand.Value.NextDouble() > 0.5;
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/CodeGenerator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/CodeGenerator.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/CodeGenerator.cs	(revision 14513)
@@ -1,78 +1,66 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Generators {
+  using System;
+  using System.Collections.Generic;
+  using System.Linq;
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Generators
-{
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Core;
+  using HeuristicLab.Random;
+
+  /// <summary>
+  ///     The following is the standard Push random code generation algorithm, which is used for the CODE.RAND instruction.
+  ///     It may also be useful for the initialization of programs in evolutionary computation systems, and it is used for
+  ///     this purpose in PushGP.
+  ///     It produces a uniform distribution of sizes and what seems to be a reasonable distribution of shapes, in a
+  ///     reasonable amount of time.
+  /// </summary>
+  /// <see cref="http://faculty.hampshire.edu/lspector/push3-description.html#RandomCode" />
+  public static class CodeGenerator {
+    private static readonly ThreadLocal<IRandom> random = RandomFactory.GetRandom();
+
     /// <summary>
-    /// The following is the standard Push random code generation algorithm, which is used for the CODE.RAND instruction.
-    /// It may also be useful for the initialization of programs in evolutionary computation systems, and it is used for this purpose in PushGP.
-    /// It produces a uniform distribution of sizes and what seems to be a reasonable distribution of shapes, in a reasonable amount of time.
+    ///     Generates a random program with a given max size
     /// </summary>
-    /// <see cref="http://faculty.hampshire.edu/lspector/push3-description.html#RandomCode"/>
-    public class CodeGenerator
-    {
-        private static IRandom random = new FastRandom();
-        private readonly IInterpreter interpreter;
+    /// <param name="maxPoints"></param>
+    /// <returns>Returns an ExpandExpression if maxPoints smaller or equal to Configuration.MaxProgramPoints and Noop otherwise</returns>
+    public static ExecExpandExpression RandomProgram(int maxPoints, IDictionary<string, Expression> customExpressions = null) {
+      var code = RandomCode(maxPoints, customExpressions).ToArray();
 
-        public CodeGenerator(IInterpreter interpreter)
-        {
-            this.interpreter = interpreter;
-        }
+      return new ExecExpandExpression(code);
+    }
 
-        /// <summary>
-        /// Generates a random program with a given max size
-        /// </summary>
-        /// <param name="maxPoints"></param>
-        /// <returns>Returns an ExpandExpression if maxPoints smaller or equal to Configuration.MaxProgramPoints and Noop otherwise</returns>
-        public Expression RandomProgram(int maxPoints)
-        {
-            return ExecExpandExpression.TryCreate(interpreter.CodeGenerator.RandomCode(maxPoints).ToArray(), interpreter.Configuration);
-        }
+    public static IEnumerable<Expression> RandomCode(int maxPoints, IDictionary<string, Expression> customExpressions = null) {
+      var actualPoints = random.Value.Next(1, Math.Max(1, maxPoints));
 
-        public IEnumerable<Expression> RandomCode(int maxPoints)
-        {
-            var actualPoints = random.Next(1, Math.Max(1, maxPoints));
+      return RandomCodeWithSize(actualPoints, customExpressions);
+    }
 
-            return RandomCodeWithSize(actualPoints);
-        }
+    private static IEnumerable<Expression> RandomCodeWithSize(
+      int points,
+      IDictionary<string, Expression> customExpressions = null) {
+      if (points == 1) {
+        var customCount = customExpressions == null ? 0 : customExpressions.Count - 1;
+        var index = random.Value.Next(0, ExpressionTable.Count + customCount - 1);
+        return new[] { CreateExpression(index, customExpressions) };
+      }
 
-        private IEnumerable<Expression> RandomCodeWithSize(int points)
-        {
-            if (points == 1)
-            {
-                var index = random.Next(0, ExpressionTable.Count + interpreter.CustomExpressions.Count - 2);
-                return new[] { CreateExpression(index) };
-            }
-            else
-            {
-                var sizesThisLevel = Decompose(points - 1, points - 1);
-                return sizesThisLevel.SelectMany(size => RandomCodeWithSize(size)).Shuffle(random);
-            }
-        }
+      var sizesThisLevel = Decompose(points - 1, points - 1);
+      return sizesThisLevel.SelectMany(size => RandomCodeWithSize(size, customExpressions)).Shuffle(random.Value);
+    }
 
-        private IEnumerable<int> Decompose(int number, int maxParts)
-        {
-            if (number == 1 || maxParts == 1)
-            {
-                return new[] { number };
-            }
-            else
-            {
-                var thisPart = random.Next(1, number - 1);
-                return new[] { thisPart }.Concat(Decompose(number - thisPart, maxParts - 1));
-            }
-        }
+    private static IEnumerable<int> Decompose(int number, int maxParts) {
+      if ((number == 1) || (maxParts == 1)) return new[] { number };
+      var thisPart = random.Value.Next(1, number - 1);
+      return new[] { thisPart }.Concat(Decompose(number - thisPart, maxParts - 1));
+    }
 
-        private Expression CreateExpression(int index)
-        {
-            return (index >= 0 && index < ExpressionTable.Count)
-                ? ExpressionTable.GetExpression(index)
-                : new NameDefineXExecExpression(interpreter.CustomExpressions.ElementAt(index - (ExpressionTable.Count - 1)).Key);
-        }
+    private static Expression CreateExpression(int index, IDictionary<string, Expression> customExpressions = null) {
+      if ((index >= 0) && (index < ExpressionTable.Count)) return ExpressionTable.GetExpression(index);
+
+      if (customExpressions == null) throw new IndexOutOfRangeException();
+      return new NameDefineXExecExpression(customExpressions.ElementAt(index - (ExpressionTable.Count - 1)).Key);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/FloatGenerator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/FloatGenerator.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/FloatGenerator.cs	(revision 14513)
@@ -1,15 +1,14 @@
-﻿using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Generators {
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Generators
-{
-    public class FloatGenerator
-    {
-        private static IRandom rand = new FastRandom();
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Core;
 
-        public static double RandomFloat(double min = double.MinValue, double max = double.MaxValue)
-        {
-            return rand.NextDouble() * (max - min) + min;
-        }
+  public class FloatGenerator {
+    private static readonly ThreadLocal<IRandom> rand = RandomFactory.GetRandom();
+
+    public static double RandomFloat(double min = double.MinValue, double max = double.MaxValue) {
+      return rand.Value.NextDouble() * (max - min) + min;
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/IntegerGenerator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/IntegerGenerator.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/IntegerGenerator.cs	(revision 14513)
@@ -1,15 +1,14 @@
-﻿using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Generators {
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Generators
-{
-    public static class IntegerGenerator
-    {
-        private static IRandom rand = new FastRandom();
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Core;
 
-        public static long RandomInteger(int min = int.MinValue, int max = int.MaxValue)
-        {
-            return rand.Next(min, max);
-        }
+  public static class IntegerGenerator {
+    private static readonly ThreadLocal<IRandom> rand = RandomFactory.GetRandom();
+
+    public static long RandomInteger(int min = int.MinValue, int max = int.MaxValue) {
+      return rand.Value.Next(min, max);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/NameGenerator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/NameGenerator.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Generators/NameGenerator.cs	(revision 14513)
@@ -1,47 +1,44 @@
-﻿using System;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Generators {
+  using System;
+  using System.Threading;
 
-namespace HeuristicLab.Algorithms.PushGP.Generators
-{
-    public class NameGenerator
-    {
-        public const int DefaultRandomNameLength = 10;
-        private static IRandom rand = new FastRandom();
-        private static char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Core;
 
-        private int index = 0;
+  public class NameGenerator {
+    public const int DefaultRandomNameLength = 10;
 
-        public string GetNextString()
-        {
-            var length = index < chars.Length ? 1 : (int)(Math.Log(index, chars.Length)) + 1;
-            var result = new char[length];
-            var tmp = index;
-            index++;
+    private static readonly ThreadLocal<IRandom> rand = RandomFactory.GetRandom();
 
-            for (var i = length; i > 0; i--)
-            {
-                var a = (int)Math.Pow(chars.Length, i - 1);
-                var b = tmp / a;
+    private static readonly char[] chars =
+      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
 
-                result[length - i] = chars[b];
+    private int index;
 
-                tmp -= a * b;
-            }
+    public string GetNextString() {
+      var length = this.index < chars.Length ? 1 : (int)Math.Log(this.index, chars.Length) + 1;
+      var result = new char[length];
+      var tmp = this.index;
+      this.index++;
 
-            return new string(result);
-        }
+      for (var i = length; i > 0; i--) {
+        var a = (int)Math.Pow(chars.Length, i - 1);
+        var b = tmp / a;
 
-        public static string RandomName(int length = DefaultRandomNameLength)
-        {
-            var name = new char[length];
+        result[length - i] = chars[b];
 
-            for (var i = 0; i < length; i++)
-            {
-                name[i] = chars[rand.Next(chars.Length)];
-            }
+        tmp -= a * b;
+      }
 
-            return new string(name);
-        }
+      return new string(result);
     }
+
+    public static string RandomName(int length = DefaultRandomNameLength) {
+      var name = new char[length];
+
+      for (var i = 0; i < length; i++) name[i] = chars[rand.Value.Next(chars.Length)];
+
+      return new string(name);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj	(revision 14513)
@@ -22,4 +22,5 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <LangVersion>5</LangVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -52,6 +53,9 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Data\ExpressionNode.cs" />
-    <Compile Include="Data\ExpressionTree.cs" />
+    <Compile Include="Data\Pool\IRecyclable.cs" />
+    <Compile Include="Data\Pool\ObjectPool.cs" />
+    <Compile Include="Data\Random\RandomFactory.cs" />
+    <Compile Include="Data\Tree\ExpressionNode.cs" />
+    <Compile Include="Data\Tree\ExpressionTree.cs" />
     <Compile Include="Exporter\Exporter.cs" />
     <Compile Include="Expressions\BooleanExpressions.cs" />
@@ -83,4 +87,6 @@
     <Compile Include="Expressions\Expression.cs" />
     <Compile Include="Expressions\NameExpressions.cs" />
+    <Compile Include="Interpreter\PooledPushGpInterpreter.cs" />
+    <Compile Include="Interpreter\PushGpInterpreterPool.cs" />
     <Compile Include="Simplifier\ISimplifier.cs" />
     <Compile Include="Simplifier\RandomSimplifier.cs" />
@@ -91,11 +97,11 @@
     <Compile Include="Interpreter\Configuration.cs" />
     <Compile Include="Generators\CodeGenerator.cs" />
-    <Compile Include="Parser\Parser.cs" />
+    <Compile Include="Parser\PushGPParser.cs" />
     <Compile Include="Stack\IStack.cs" />
     <Compile Include="Interpreter\PushGPInterpreter.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Interpreter\IInterpreter.cs" />
+    <Compile Include="Interpreter\IPushGpInterpreter.cs" />
     <Compile Include="Stack\PushGPStack.cs" />
-    <Compile Include="ExpressionTable.cs" />
+    <Compile Include="Expressions\ExpressionTable.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj.user
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj.user	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.csproj.user	(revision 14513)
@@ -2,5 +2,5 @@
 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <ProjectView>ProjectFiles</ProjectView>
+    <ProjectView>ShowAllFiles</ProjectView>
   </PropertyGroup>
 </Project>
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/Configuration.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/Configuration.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/Configuration.cs	(revision 14513)
@@ -1,109 +1,120 @@
-﻿using System.Collections.Generic;
-using HeuristicLab.Algorithms.PushGP.Expressions;
+﻿namespace HeuristicLab.Algorithms.PushGP.Interpreter {
+  using System.Collections.Generic;
 
-namespace HeuristicLab.Algorithms.PushGP.Interpreter
-{
-    public class Configuration
-    {
-        public Configuration()
-        {
-            IsBooleanStackEnabled = true;
-            IsIntegerStackEnabled = true;
-            IsFloatStackEnabled = true;
-            IsCodeStackEnabled = true;
-            IsNameStackEnabled = true;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
 
-            EvalPushLimit = 4096;
-            MaxPointsInProgram = 128;
-            MaxPointsInRandomExpression = 1024;
+  public class Configuration {
+    public Configuration() {
+      this.IsBooleanStackEnabled = true;
+      this.IsIntegerStackEnabled = true;
+      this.IsFloatStackEnabled = true;
+      this.IsCodeStackEnabled = true;
+      this.IsNameStackEnabled = true;
 
-            TopLevelPushCode = true;
-            TopLevelPopCode = false;
+      this.EvalPushLimit = 4096;
+      this.MaxPointsInProgram = 128;
+      this.MaxPointsInRandomExpression = 1024;
 
-            RandomSeedMax = 30081;
-            RandomSeedMin = 0;
-            RandomSeed = null;
+      this.TopLevelPushCode = true;
+      this.TopLevelPopCode = false;
 
-            MinRandomInteger = -128;
-            MaxRandomInteger = 128;
-            MinRandomFloat = -128D;
-            MaxRandomFloat = 128D;
-            NewErcNameProbability = 0.5;
-        }
+      this.RandomSeedMax = 30081;
+      this.RandomSeedMin = 0;
+      this.RandomSeed = null;
 
-        public bool IsBooleanStackEnabled { get; set; }
-        public bool IsIntegerStackEnabled { get; set; }
-        public bool IsFloatStackEnabled { get; set; }
-        public bool IsCodeStackEnabled { get; set; }
-        public bool IsNameStackEnabled { get; set; }
+      this.MinRandomInteger = -128;
+      this.MaxRandomInteger = 128;
+      this.MinRandomFloat = -128D;
+      this.MaxRandomFloat = 128D;
+      this.NewErcNameProbability = 0.5;
+    }
 
-        public IList<string> AllowedInstructions { get; set; }
+    public bool IsBooleanStackEnabled { get; set; }
 
-        public IList<Expression> PredefinedExpressions { get; set; }
+    public bool IsIntegerStackEnabled { get; set; }
 
-        /// <summary>
-        /// This is the maximum allowed number of "executions" in a single top-level call to the interpreter.
-        /// The execution of a single Push instruction counts as one execution, as does the processing of a single literal,
-        /// as does the descent into one layer of parentheses (that is, the processing of the "(" counts as one execution).
-        /// When this limit is exceeded the interpreter aborts immediately, leaving its stacks in the states they were in prior
-        /// to the abort (so they may still be examined by a calling program). Whether or not this counts as an "abnormal" termination
-        /// is up to the calling program.
-        /// </summary>
-        public uint EvalPushLimit { get; set; }
+    public bool IsFloatStackEnabled { get; set; }
 
-        /// <summary>
-        /// This is the maximum size of an item on the CODE stack, expressed as a number of points.
-        /// A point is an instruction, a literal, or a pair of parentheses. Any instruction that would cause this limit to be exceeded
-        /// should instead act as a NOOP, leaving all stacks in the states that they were in before the execution of the instruction.
-        /// </summary>
-        public uint MaxPointsInProgram { get; set; }
+    public bool IsCodeStackEnabled { get; set; }
 
-        /// <summary>
-        /// The maximum number of points in an expression produced by the CODE.RAND instruction.
-        /// </summary>
-        public uint MaxPointsInRandomExpression { get; set; }
+    public bool IsNameStackEnabled { get; set; }
 
-        /// <summary>
-        /// When TRUE (which is the default), code passed to the top level of the interpreter
-        /// will be pushed onto the CODE stack prior to execution.
-        /// </summary>
-        public bool TopLevelPushCode { get; set; }
+    public IList<string> AllowedInstructions { get; set; }
 
-        /// <summary>
-        /// When TRUE, the CODE stack will be popped at the end of top level calls to the interpreter. The default is FALSE.
-        /// </summary>
-        public bool TopLevelPopCode { get; set; }
+    public IList<Expression> PredefinedExpressions { get; set; }
 
-        /// <summary>
-        /// The minimum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
-        /// </summary>
-        public int MinRandomInteger { get; set; }
+    /// <summary>
+    ///     This is the maximum allowed number of "executions" in a single top-level call to the interpreter.
+    ///     The execution of a single Push instruction counts as one execution, as does the processing of a single literal,
+    ///     as does the descent into one layer of parentheses (that is, the processing of the "(" counts as one execution).
+    ///     When this limit is exceeded the interpreter aborts immediately, leaving its stacks in the states they were in prior
+    ///     to the abort (so they may still be examined by a calling program). Whether or not this counts as an "abnormal"
+    ///     termination
+    ///     is up to the calling program.
+    /// </summary>
+    public int EvalPushLimit { get; set; }
 
-        /// <summary>
-        /// The maximum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
-        /// </summary>
-        public int MaxRandomInteger { get; set; }
+    /// <summary>
+    /// This is the maximum of depth a push program can have. Expressions, which lead to exceed this limit are interpreted as NOOP.
+    /// </summary>
+    public int MaxDepth { get; set; }
 
-        /// <summary>
-        /// The minimum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
-        /// </summary>
-        public double MinRandomFloat { get; set; }
+    /// <summary>
+    ///     This is the maximum size of an item on the CODE stack, expressed as a number of points.
+    ///     A point is an instruction, a literal, or a pair of parentheses. Any instruction that would cause this limit to be
+    ///     exceeded
+    ///     should instead act as a NOOP, leaving all stacks in the states that they were in before the execution of the
+    ///     instruction.
+    /// </summary>
+    public int MaxPointsInProgram { get; set; }
 
-        /// <summary>
-        /// The maximum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
-        /// </summary>
-        public double MaxRandomFloat { get; set; }
+    /// <summary>
+    ///     The maximum number of points in an expression produced by the CODE.RAND instruction.
+    /// </summary>
+    public int MaxPointsInRandomExpression { get; set; }
 
-        /// <summary>
-        /// The probability that the selection of the ephemeral
-        /// random NAME constant for inclusion in randomly generated code will produce a new name
-        /// (rather than a name that was previously generated).
-        /// </summary>
-        public double NewErcNameProbability { get; set; }
+    /// <summary>
+    ///     When TRUE (which is the default), code passed to the top level of the interpreter
+    ///     will be pushed onto the CODE stack prior to execution.
+    /// </summary>
+    public bool TopLevelPushCode { get; set; }
 
-        public ushort RandomSeedMax { get; set; }
-        public ushort RandomSeedMin { get; set; }
+    /// <summary>
+    ///     When TRUE, the CODE stack will be popped at the end of top level calls to the interpreter. The default is FALSE.
+    /// </summary>
+    public bool TopLevelPopCode { get; set; }
 
-        public ushort? RandomSeed { get; set; }
-    }
+    /// <summary>
+    ///     The minimum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
+    /// </summary>
+    public int MinRandomInteger { get; set; }
+
+    /// <summary>
+    ///     The maximum INTEGER that will be produced as an ephemeral random INTEGER constant or from a call to INTEGER.RAND.
+    /// </summary>
+    public int MaxRandomInteger { get; set; }
+
+    /// <summary>
+    ///     The minimum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
+    /// </summary>
+    public double MinRandomFloat { get; set; }
+
+    /// <summary>
+    ///     The maximum FLOAT that will be produced as an ephemeral random FLOAT constant or from a call to FLOAT.RAND.
+    /// </summary>
+    public double MaxRandomFloat { get; set; }
+
+    /// <summary>
+    ///     The probability that the selection of the ephemeral
+    ///     random NAME constant for inclusion in randomly generated code will produce a new name
+    ///     (rather than a name that was previously generated).
+    /// </summary>
+    public double NewErcNameProbability { get; set; }
+
+    public ushort RandomSeedMax { get; set; }
+
+    public ushort RandomSeedMin { get; set; }
+
+    public ushort? RandomSeed { get; set; }
+  }
 }
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/IInterpreter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/IInterpreter.cs	(revision 14512)
+++ 	(revision )
@@ -1,37 +1,0 @@
-﻿using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Stack;
-
-namespace HeuristicLab.Algorithms.PushGP.Interpreter
-{
-    public interface IInterpreter
-    {
-        IStack<Expression> CodeStack { get; }
-        IStack<Expression> ExecStack { get; }
-        IStack<string> NameStack { get; }
-        IStack<bool> BooleanStack { get; }
-        IStack<long> IntegerStack { get; }
-        IStack<double> FloatStack { get; }
-        IDictionary<string, Expression> CustomExpressions { get; }
-
-        Configuration Configuration { get; }
-
-        CodeGenerator CodeGenerator { get; }
-
-        bool IsNameQuoteFlagSet { get; set; }
-
-        void Interpret(string code);
-        Task InterpretAsync(string code, bool paused = false, CancellationToken token = default(CancellationToken));
-        void Interpret(Expression program);
-        Task InterpretAsync(Expression program, bool paused = false, CancellationToken token = default(CancellationToken));
-        Task AbortAndResetAsync();
-        Task AbortAsync();
-        Task PauseAsync();
-        Task ResumeAsync();
-        void Step();
-        void PrintStacks();
-    }
-}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/IPushGpInterpreter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/IPushGpInterpreter.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/IPushGpInterpreter.cs	(revision 14513)
@@ -0,0 +1,48 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Interpreter {
+  using System;
+  using System.Collections.Generic;
+  using System.Threading;
+  using System.Threading.Tasks;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  public interface IPushGpInterpreter {
+    IStack<Expression> CodeStack { get; }
+
+    IStack<Expression> ExecStack { get; }
+
+    IStack<string> NameStack { get; }
+
+    IStack<bool> BooleanStack { get; }
+
+    IStack<long> IntegerStack { get; }
+
+    IStack<double> FloatStack { get; }
+
+    IDictionary<string, Expression> CustomExpressions { get; }
+
+    Configuration Configuration { get; }
+
+    bool IsNameQuoteFlagSet { get; set; }
+
+    void Interpret(string code);
+
+    Task InterpretAsync(string code, bool paused = false, CancellationToken token = default(CancellationToken));
+
+    void Interpret(Expression program);
+
+    Task InterpretAsync(Expression program, bool paused = false, CancellationToken token = default(CancellationToken));
+
+    Task AbortAndResetAsync();
+
+    Task AbortAsync();
+
+    Task PauseAsync();
+
+    Task ResumeAsync();
+
+    void Step();
+
+    void PrintStacks();
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PooledPushGpInterpreter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PooledPushGpInterpreter.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PooledPushGpInterpreter.cs	(revision 14513)
@@ -0,0 +1,24 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Interpreter {
+  using System;
+
+  using HeuristicLab.Algorithms.PushGP.Data.Pool;
+
+  public class PooledPushGpInterpreter : PushGpInterpreter, IRecyclable, IDisposable {
+
+    private readonly PushGpInterpreterPool container;
+
+    public PooledPushGpInterpreter(PushGpInterpreterPool container, Configuration config)
+      : base(config) {
+      this.container = container;
+    }
+
+    void IRecyclable.Recycle() {
+      this.Reset();
+      this.Configuration = this.container.Configuration;
+    }
+
+    public void Dispose() {
+      this.container.Free(this);
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGPInterpreter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGPInterpreter.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGPInterpreter.cs	(revision 14513)
@@ -1,247 +1,223 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Stack;
-
-namespace HeuristicLab.Algorithms.PushGP.Interpreter
-{
-    public class PushGPInterpreter : IInterpreter
+﻿namespace HeuristicLab.Algorithms.PushGP.Interpreter {
+  using System;
+  using System.Collections.Generic;
+  using System.Threading;
+  using System.Threading.Tasks;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Parser;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  public class PushGpInterpreter : IPushGpInterpreter {
+    private Task currentTask;
+
+    public PushGpInterpreter(Configuration config = null) {
+      this.Configuration = config ?? new Configuration();
+
+      // setting the capacity of the stacks to max points ensures that there will be enough memory at runtime
+      this.CodeStack = new PushGPStack<Expression>(this.Configuration.MaxPointsInProgram);
+      this.ExecStack = new PushGPStack<Expression>(this.Configuration.MaxPointsInProgram);
+      this.NameStack = new PushGPStack<string>(16);
+      this.BooleanStack = new PushGPStack<bool>(16);
+      this.IntegerStack = new PushGPStack<long>(16);
+      this.FloatStack = new PushGPStack<double>(16);
+
+      this.CustomExpressions = new Dictionary<string, Expression>();
+    }
+
+    public int ExecCounter { get; private set; }
+
+    public bool IsPaused { get; private set; }
+
+    public bool IsAborted { get; private set; }
+
+    public bool IsRunning
     {
-        private Task currentTask;
-
-
-        public PushGPInterpreter(Configuration config = null)
-        {
-            Configuration = config ?? new Configuration();
-
-            CodeStack = new PushGPStack<Expression>(128);
-            ExecStack = new PushGPStack<Expression>(128);
-            NameStack = new PushGPStack<string>(16);
-            BooleanStack = new PushGPStack<bool>(16);
-            IntegerStack = new PushGPStack<long>(16);
-            FloatStack = new PushGPStack<double>(16);
-
-            CustomExpressions = new Dictionary<string, Expression>();
-
-            CodeGenerator = new CodeGenerator(this);
-        }
-
-        public Configuration Configuration { get; private set; }
-
-        public int ExecCounter { get; private set; }
-        public bool IsPaused { get; private set; }
-        public bool IsAborted { get; private set; }
-        public bool IsRunning { get { return ExecStack.Count > 0 && !IsPaused && !IsAborted && ExecCounter < Configuration.EvalPushLimit; } }
-        public bool IsCompleted { get { return ExecStack.Count == 0; } }
-        public bool CanStep { get { return !IsCompleted && !IsAborted && IsPaused; } }
-
-        public IStack<Expression> CodeStack { get; private set; }
-        public IStack<Expression> ExecStack { get; private set; }
-        public IStack<string> NameStack { get; private set; }
-        public IStack<bool> BooleanStack { get; private set; }
-        public IStack<long> IntegerStack { get; private set; }
-        public IStack<double> FloatStack { get; private set; }
-
-        public IDictionary<string, Expression> CustomExpressions { get; private set; }
-
-        public CodeGenerator CodeGenerator { get; private set; }
-
-        public bool IsNameQuoteFlagSet { get; set; }
-
-        public void Reset()
-        {
-            IsAborted = false;
-            IsPaused = false;
-            currentTask = null;
-
-            Clear();
-        }
-
-        public void Clear()
-        {
-            ExecCounter = 0;
-
-            ExecStack.Clear();
-            CodeStack.Clear();
-            NameStack.Clear();
-            BooleanStack.Clear();
-            IntegerStack.Clear();
-            FloatStack.Clear();
-
-            CustomExpressions.Clear();
-        }
-
-        public void Interpret(string code)
-        {
-            var program = Encode(code);
-            Interpret(program);
-        }
-
-        public Task InterpretAsync(string code, bool paused = false, CancellationToken token = default(CancellationToken))
-        {
-            var program = Encode(code);
-
-            currentTask = InterpretAsync(program, paused, token);
-
-            return currentTask;
-        }
-
-        public Task InterpretAsync(Expression program, bool paused = false, CancellationToken token = default(CancellationToken))
-        {
-            IsPaused = paused;
-            currentTask = Task.Run(() => Interpret(program), token);
-
-            return currentTask;
-        }
-
-        public void Interpret(Expression program)
-        {
-            /* Push top expression so the loop is able to enter
-             * If the top expression is a single statement then the loop has nothing to do
-             * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack */
-            ExecStack.Push(program);
-
-            if (Configuration.TopLevelPushCode)
-            {
-                CodeStack.Insert(0, program);
-            }
-
-            // run top expression
-            ExecStack.Pop().Eval(this);
-
-            Interpret();
-        }
-
-        private void Interpret()
-        {
-            while (IsRunning)
-            {
-                DoStep();
-                ExecCounter++;
-            }
-
-            Finally();
-        }
-
-        private void Finally()
-        {
-            if (IsCompleted && Configuration.TopLevelPopCode && CodeStack.Count > 0)
-            {
-                CodeStack.Pop();
-            }
-        }
-
-        private void DoStep()
-        {
-            ExecStack.Pop().Eval(this);
-        }
-
-        private Task InterpreteAsync()
-        {
-            currentTask = Task.Run(() => Interpret());
-
-            return currentTask;
-        }
-
-        public async Task AbortAsync()
-        {
-            if (IsAborted || IsCompleted)
-                return;
-
-            IsAborted = true;
-
-            if (currentTask != null)
-            {
-                await currentTask;
-            }
-        }
-
-        public async Task AbortAndResetAsync()
-        {
-            await AbortAsync();
-            Reset();
-        }
-
-        public async Task PauseAsync()
-        {
-            if (IsPaused || IsCompleted)
-                return;
-
-            IsPaused = true;
-
-            if (currentTask != null)
-            {
-                await currentTask;
-            }
-        }
-
-        public Task ResumeAsync()
-        {
-            if (IsPaused || !IsAborted)
-            {
-                IsPaused = false;
-                return InterpreteAsync();
-            }
-
-            return currentTask;
-        }
-
-        public void Step()
-        {
-            if (CanStep)
-            {
-                DoStep();
-                Finally();
-            }
-        }
-
-        public void Step(int count)
-        {
-            for (var i = 0; i < count; i++)
-            {
-                Step();
-            }
-        }
-
-        public static Expression Encode(string code)
-        {
-            return Parser.Parse(code);
-        }
-
-        public static Task<Expression> EncodeAsync(string code, CancellationToken token = default(CancellationToken))
-        {
-            return Task.Run(() => Encode(code), token);
-        }
-
-        public static string Decode(Expression expression)
-        {
-            return string.Concat(expression.ToString());
-        }
-
-        public static Task<string> DecodeAsync(Expression expression, CancellationToken token = default(CancellationToken))
-        {
-            return Task.Run(() => Decode(expression), token);
-        }
-
-        public void PrintStacks()
-        {
-            PrintStack("EXEC", ExecStack);
-            PrintStack("CODE", CodeStack);
-            PrintStack("NAME", NameStack);
-            PrintStack("BOOLEAN", BooleanStack);
-            PrintStack("FLOAT", FloatStack);
-            PrintStack("INTEGER", IntegerStack);
-        }
-
-        private void PrintStack<T>(string name, IStack<T> stack)
-        {
-            Console.WriteLine(string.Format(
-                "--- {0} ---\n{1}\n---------------------------------------------------",
-                name,
-                stack));
-        }
-    }
+      get
+      {
+        return !this.ExecStack.IsEmpty &&
+               !this.IsPaused &&
+               !this.IsAborted &&
+               (this.ExecCounter < this.Configuration.EvalPushLimit);
+      }
+    }
+
+    public bool IsCompleted
+    {
+      get
+      {
+        return this.ExecStack.Count == 0;
+      }
+    }
+
+    public bool CanStep
+    {
+      get
+      {
+        return !this.IsCompleted && !this.IsAborted && this.IsPaused;
+      }
+    }
+
+    public Configuration Configuration { get; protected set; }
+
+    public IStack<Expression> CodeStack { get; private set; }
+
+    public IStack<Expression> ExecStack { get; private set; }
+
+    public IStack<string> NameStack { get; private set; }
+
+    public IStack<bool> BooleanStack { get; private set; }
+
+    public IStack<long> IntegerStack { get; private set; }
+
+    public IStack<double> FloatStack { get; private set; }
+
+    public IDictionary<string, Expression> CustomExpressions { get; private set; }
+
+    public bool IsNameQuoteFlagSet { get; set; }
+
+    public void Interpret(string code) {
+      var program = PushGPParser.Parse(code);
+      this.Interpret(program);
+    }
+
+    public Task InterpretAsync(string code, bool paused = false, CancellationToken token = default(CancellationToken)) {
+      var program = PushGPParser.Parse(code);
+
+      this.currentTask = this.InterpretAsync(program, paused, token);
+
+      return this.currentTask;
+    }
+
+    public Task InterpretAsync(
+      Expression program,
+      bool paused = false,
+      CancellationToken token = default(CancellationToken)) {
+      this.IsPaused = paused;
+      this.currentTask = Task.Run(() => this.Interpret(program), token);
+
+      return this.currentTask;
+    }
+
+    public void Interpret(Expression program) {
+      /* Push top expression so the loop is able to enter
+       * If the top expression is a single statement then the loop has nothing to do
+       * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack */
+      this.ExecStack.Push(program);
+
+      if (this.Configuration.TopLevelPushCode) this.CodeStack.Insert(0, program);
+
+      // run top expression
+      this.DoStep();
+
+      this.Interpret();
+    }
+
+    public async Task AbortAsync() {
+      if (this.IsAborted || this.IsCompleted) return;
+
+      this.IsAborted = true;
+
+      if (this.currentTask != null) await this.currentTask;
+    }
+
+    public async Task AbortAndResetAsync() {
+      await this.AbortAsync();
+      this.Reset();
+    }
+
+    public async Task PauseAsync() {
+      if (this.IsPaused || this.IsCompleted) return;
+
+      this.IsPaused = true;
+
+      if (this.currentTask != null) await this.currentTask;
+    }
+
+    public Task ResumeAsync() {
+      if (this.IsPaused || !this.IsAborted) {
+        this.IsPaused = false;
+        return this.InterpreteAsync();
+      }
+
+      return this.currentTask;
+    }
+
+    public void Step() {
+      if (!this.CanStep) return;
+      this.DoStep();
+      this.Finally();
+    }
+
+    public void Step(int count) {
+      for (var i = 0; i < count; i++) this.Step();
+    }
+
+    public void PrintStacks() {
+      this.PrintStack("EXEC", this.ExecStack);
+      this.PrintStack("CODE", this.CodeStack);
+      this.PrintStack("NAME", this.NameStack);
+      this.PrintStack("BOOLEAN", this.BooleanStack);
+      this.PrintStack("FLOAT", this.FloatStack);
+      this.PrintStack("INTEGER", this.IntegerStack);
+    }
+
+    /// <summary>
+    /// Clears stacks and
+    /// </summary>
+    public void Reset() {
+      this.IsAborted = false;
+      this.IsPaused = false;
+      this.currentTask = null;
+
+      this.Clear();
+    }
+
+    /// <summary>
+    /// Clears stacks
+    /// </summary>
+    public void Clear() {
+      this.ExecCounter = 0;
+
+      this.ExecStack.Clear();
+      this.CodeStack.Clear();
+
+      this.NameStack.Clear();
+      this.BooleanStack.Clear();
+      this.IntegerStack.Clear();
+      this.FloatStack.Clear();
+
+      this.CustomExpressions.Clear();
+    }
+
+    private void Interpret() {
+      while (this.IsRunning) {
+        this.DoStep();
+        this.ExecCounter++;
+      }
+
+      this.Finally();
+    }
+
+    private void Finally() {
+      if (!this.IsCompleted)
+        return;
+
+      if (this.Configuration.TopLevelPopCode && (this.CodeStack.Count > 0))
+        this.CodeStack.Pop();
+    }
+
+    private void DoStep() {
+      this.ExecStack.Pop().Eval(this);
+    }
+
+    private Task InterpreteAsync() {
+      this.currentTask = Task.Run(() => this.Interpret());
+
+      return this.currentTask;
+    }
+
+    private void PrintStack<T>(string name, IStack<T> stack) {
+      Console.WriteLine("--- {0} ---\n{1}\n---------------------------------------------------", name, stack);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGpInterpreterPool.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGpInterpreterPool.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Interpreter/PushGpInterpreterPool.cs	(revision 14513)
@@ -0,0 +1,29 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Interpreter {
+  using System;
+
+  using HeuristicLab.Algorithms.PushGP.Data.Pool;
+
+  public class PushGpInterpreterPool {
+    private readonly ObjectPool<PooledPushGpInterpreter> pool;
+
+    public PushGpInterpreterPool(Configuration config = null)
+      : this(Environment.ProcessorCount * 2, config) {
+    }
+
+    public PushGpInterpreterPool(int size, Configuration config = null) {
+      Configuration = config ?? new Configuration();
+
+      pool = new ObjectPool<PooledPushGpInterpreter>(() => new PooledPushGpInterpreter(this, Configuration), size);
+    }
+
+    public Configuration Configuration { get; private set; }
+
+    public PooledPushGpInterpreter GetInstance() {
+      return pool.Allocate();
+    }
+
+    public void Free(PooledPushGpInterpreter interpreter) {
+      pool.Free(interpreter);
+    }
+  }
+}
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Parser/Parser.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Parser/Parser.cs	(revision 14512)
+++ 	(revision )
@@ -1,103 +1,0 @@
-﻿using System.Collections.Generic;
-using System.Globalization;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-
-namespace HeuristicLab.Algorithms.PushGP
-{
-    public static class Parser
-    {
-        private static readonly CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture("en-US");
-
-        private const string openBrace = "(";
-        private const string closeBrace = ")";
-        private const char delimiter = ' ';
-        private static readonly char[] symbolTrim = new[] { '\r', '\n' };
-
-        public static Expression Parse(string source, int startIndex = 0)
-        {
-            var symbols = source.Split(delimiter);
-
-            int endIndex;
-            return Parse(symbols, 0, out endIndex);
-        }
-
-        private static Expression Parse(string[] symbols, int startIndex, out int endIndex)
-        {
-            var expressions = new List<Expression>();
-
-            for (var i = startIndex; i < symbols.Length; i++)
-            {
-                var symbol = symbols[i].TrimEnd(symbolTrim);
-
-                if (string.IsNullOrWhiteSpace(symbol))
-                {
-                    continue;
-                }
-
-                if (symbol == openBrace)
-                {
-                    var subExpression = Parse(symbols, i + 1, out endIndex);
-                    expressions.Insert(0, subExpression);
-                    i = endIndex;
-                    continue;
-                }
-                else if (symbol == closeBrace)
-                {
-                    endIndex = i;
-                    return new ExecExpandExpression(expressions.ToArray());
-                }
-
-                // literal
-                Expression expression;
-                if (TryParseLiteral(symbol, out expression))
-                {
-                    expressions.Insert(0, expression);
-                    continue;
-                }
-
-                // expression
-                if (ExpressionTable.TryGetStatelessExpression(symbol, out expression) ||
-                    ExpressionTable.TryGetStatefullExpression(symbol, out expression))
-                {
-                    expressions.Insert(0, expression);
-                    continue;
-                }
-
-                // identifier - custom expression or named literals
-                expressions.Insert(0, new NameDefineXExecExpression(symbol));
-            }
-
-            endIndex = symbols.Length - 1;
-            return expressions.Count == 1
-                ? expressions[0]
-                : new ExecExpandExpression(expressions.ToArray());
-        }
-
-        private static bool TryParseLiteral(string word, out Expression expression)
-        {
-            long longValue;
-            if (long.TryParse(word, out longValue))
-            {
-                expression = new IntegerPushExpression(longValue);
-                return true;
-            }
-
-            double floatValue;
-            if (double.TryParse(word, NumberStyles.Float, cultureInfo, out floatValue))
-            {
-                expression = new FloatPushExpression(floatValue);
-                return true;
-            }
-
-            bool booleanValue;
-            if (bool.TryParse(word, out booleanValue))
-            {
-                expression = new BooleanPushExpression(booleanValue);
-                return true;
-            }
-
-            expression = null;
-            return false;
-        }
-    }
-}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Parser/PushGPParser.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Parser/PushGPParser.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Parser/PushGPParser.cs	(revision 14513)
@@ -0,0 +1,92 @@
+﻿namespace HeuristicLab.Algorithms.PushGP.Parser {
+  using System.Collections.Generic;
+  using System.Globalization;
+
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+
+  public static class PushGPParser {
+    private const string openBrace = "(";
+
+    private const string closeBrace = ")";
+
+    private const char delimiter = ' ';
+
+    private static readonly CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture("en-US");
+
+    private static readonly char[] symbolTrim = { '\r', '\n' };
+
+    public static Expression Parse(string source, int startIndex = 0) {
+      var symbols = source.Split(delimiter);
+
+      int endIndex;
+      return Parse(symbols, 0, out endIndex);
+    }
+
+    private static Expression Parse(string[] symbols, int startIndex, out int endIndex) {
+      var expressions = new List<Expression>();
+
+      for (var i = startIndex; i < symbols.Length; i++) {
+        var symbol = symbols[i].TrimEnd(symbolTrim);
+
+        if (string.IsNullOrWhiteSpace(symbol)) continue;
+
+        switch (symbol) {
+          case openBrace:
+            var subExpression = Parse(symbols, i + 1, out endIndex);
+            expressions.Insert(0, subExpression);
+            i = endIndex;
+            continue;
+          case closeBrace:
+            endIndex = i;
+            return new ExecExpandExpression(expressions.ToArray());
+        }
+
+        // literal
+        Expression expression;
+        if (TryParseLiteral(symbol, out expression)) {
+          expressions.Insert(0, expression);
+          continue;
+        }
+
+        // expression
+        if (ExpressionTable.TryGetStatelessExpression(symbol, out expression)
+            || ExpressionTable.TryGetStatefullExpression(symbol, out expression)) {
+          expressions.Insert(0, expression);
+          continue;
+        }
+
+        // identifier - custom expression or named literals
+        expressions.Insert(0, new NameDefineXExecExpression(symbol));
+      }
+
+      endIndex = symbols.Length - 1;
+
+      return expressions.Count == 1
+        ? expressions[0]
+        : new ExecExpandExpression(expressions.ToArray());
+    }
+
+    private static bool TryParseLiteral(string word, out Expression expression) {
+      long longValue;
+      if (long.TryParse(word, out longValue)) {
+        expression = new IntegerPushExpression(longValue);
+        return true;
+      }
+
+      double floatValue;
+      if (double.TryParse(word, NumberStyles.Float, cultureInfo, out floatValue)) {
+        expression = new FloatPushExpression(floatValue);
+        return true;
+      }
+
+      bool booleanValue;
+      if (bool.TryParse(word, out booleanValue)) {
+        expression = new BooleanPushExpression(booleanValue);
+        return true;
+      }
+
+      expression = null;
+      return false;
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Properties/AssemblyInfo.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Properties/AssemblyInfo.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Properties/AssemblyInfo.cs	(revision 14513)
@@ -1,4 +1,3 @@
 ﻿using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
@@ -6,4 +5,5 @@
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
+
 [assembly: AssemblyTitle("HeuristicLab.Algorithms.PushGP")]
 [assembly: AssemblyDescription("")]
@@ -18,7 +18,9 @@
 // to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
+
 [assembly: ComVisible(false)]
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
+
 [assembly: Guid("368d1303-470c-4f31-91f2-0fad379daa45")]
 
@@ -33,4 +35,5 @@
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/ISimplifier.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/ISimplifier.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/ISimplifier.cs	(revision 14513)
@@ -1,9 +1,9 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
+﻿namespace HeuristicLab.Algorithms.PushGP.Simplifier {
+  using System;
 
-namespace HeuristicLab.Algorithms.PushGP.Simplifier
-{
-    public interface ISimplifier
-    {
-        Expression Simplify(Expression program);
-    }
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+
+  public interface ISimplifier {
+    ExecExpandExpression Simplify(ExecExpandExpression program, Predicate<ExecExpandExpression> isBetter);
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/RandomSimplifier.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/RandomSimplifier.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Simplifier/RandomSimplifier.cs	(revision 14513)
@@ -1,28 +1,62 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.Algorithms.PushGP.Simplifier {
+  using System;
+  using System.Threading;
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Core;
 
-namespace HeuristicLab.Algorithms.PushGP.Simplifier
-{
-    public class RandomSimplifier : ISimplifier
-    {
-        private IRandom rand = new FastRandom();
-        public int Trys { get; set; }
+  public class RandomSimplifier : ISimplifier {
+    private static readonly ThreadLocal<IRandom> random = RandomFactory.GetRandom();
 
-        public Expression Simplify(Expression program)
-        {
-            if (program.GetType() != typeof(ExecExpandExpression))
-                return program;
+    public int Trys { get; set; }
 
-            var clone = program.Clone() as ExecExpandExpression;
+    public ExecExpandExpression Simplify(ExecExpandExpression program, Predicate<ExecExpandExpression> isBetter) {
 
-            for (var i = 0; i < Trys; i++)
-            {
-                var index = rand.Next(0, clone.TotalCount - 1);
+      if (program.TotalCount == 1) {
+        return isBetter(ExecExpandExpression.Empty) ? ExecExpandExpression.Empty : program;
+      }
 
-            }
+      var copy = program.Copy();
+      var maxTrys = Math.Min(Trys, program.TotalCount - 2);
+      var sucessfullRemoves = 0;
 
-            return clone;
+      for (var i = 0; i < maxTrys; i++) {
+        var rndIndex = random.Value.Next(1, program.TotalCount - 1 - sucessfullRemoves);
+        var node = copy.GetFromTree(
+          rndIndex,
+          (super, parent, child, childIndex, parentIndex) => new {
+            Super = super,
+            Parent = parent,
+            ChildIndex = childIndex,
+            ParentIndex = parentIndex
+          });
+
+        var oldParentExpressions = node.Parent.Expressions as Expression[];
+        var newParentExpressions = RemoveAt(oldParentExpressions, node.ChildIndex);
+        var newParent = new ExecExpandExpression(newParentExpressions);
+
+        var superExpressions = (node.Super == null ? copy.Expressions : node.Super.Expressions) as Expression[];
+        superExpressions[node.ParentIndex] = newParent;
+
+        if (isBetter(copy)) {
+          sucessfullRemoves++;
+        } else {
+          superExpressions[node.ParentIndex] = node.Parent;
         }
+      }
+
+      return copy;
     }
+
+    private static T[] RemoveAt<T>(T[] source, int index) {
+      var dest = new T[source.Length - 1];
+      if (index > 0)
+        Array.Copy(source, 0, dest, 0, index);
+
+      if (index < source.Length - 1)
+        Array.Copy(source, index + 1, dest, index, source.Length - index - 1);
+
+      return dest;
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/IStack.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/IStack.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/IStack.cs	(revision 14513)
@@ -1,34 +1,56 @@
-﻿using System;
-using System.Collections.Generic;
+﻿namespace HeuristicLab.Algorithms.PushGP.Stack {
+  using System;
+  using System.Collections.Generic;
 
-namespace HeuristicLab.Algorithms.PushGP.Stack
-{
-    public interface IStack<T> : IEnumerable<T>, ICollection<T>
-    {
-        void Swap(int count);
-        void Yank(int index);
-        bool IsEmpty { get; }
-        void Push(T item);
-        void Push(params T[] items);
-        void Push(IEnumerable<T> items);
-        void PushResult(int count, Func<T[], T> templateFunc);
-        void Insert(int index, T item);
-        void Insert(int index, params T[] items);
-        void Insert(int index, IEnumerable<T> items);
-        T ReverseElementAt(int offset);
-        void SetTop(T value);
-        void RemoveTop();
-        void Remove(int count);
-        void RemoveAt(int index);
-        void RemoveAt(int index, int count);
-        T Pop();
-        T[] Pop(int count);
-        bool TryPop(out T item);
-        T ElementAt(int index);
-        T Top { get; }
-        T TopOrDefault { get; }
-        T Bottom { get; }
-        T BottomOrDefault { get; }
-        T this[int key] { get; set; }
-    }
+  public interface IStack<T> : ICollection<T> {
+    bool IsEmpty { get; }
+
+    T Top { get; }
+
+    T TopOrDefault { get; }
+
+    T Bottom { get; }
+
+    T BottomOrDefault { get; }
+
+    T this[int key] { get; set; }
+
+    void Swap(int count);
+
+    void Yank(int index);
+
+    void Push(T item);
+
+    void Push(params T[] items);
+
+    void Push(IEnumerable<T> items);
+
+    void PushResult(int count, Func<T[], T> templateFunc);
+
+    void Insert(int index, T item);
+
+    void Insert(int index, params T[] items);
+
+    void Insert(int index, IEnumerable<T> items);
+
+    T ReverseElementAt(int offset);
+
+    void SetTop(T value);
+
+    void RemoveTop();
+
+    void Remove(int count);
+
+    void RemoveAt(int index);
+
+    void RemoveAt(int index, int count);
+
+    T Pop();
+
+    T[] Pop(int count);
+
+    bool TryPop(out T item);
+
+    T ElementAt(int index);
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/PushGPStack.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/PushGPStack.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Stack/PushGPStack.cs	(revision 14513)
@@ -1,234 +1,245 @@
-﻿using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace HeuristicLab.Algorithms.PushGP.Stack
-{
-    /// <summary>
-    /// While Push's stacks are generally treated as genuine stacks---that is, inclassions take their arguments from the tops of
-    /// the stacks and push their results onto the tops of the stacks---a few inclassions (like YANK and SHOVE) do allow direct access
-    /// to "deep" stack elements by means of integer indices. To this extent the stacks can be used as general, random access memory
-    /// classures. This is one of the features that ensures the Turing-completeness of Push (another being the arbitrary name/value
-    /// bindings supported by the NAME data type and DEFINE methods; see below).
-    /// </summary>
-    /// <typeparam name="T">The item type of the collection.</typeparam>
-    public class PushGPStack<T> : IStack<T>
-    {
-        private readonly List<T> data;
-        private const string Delimiter = " ";
-
-        public PushGPStack(int capacity = 0)
-        {
-            data = new List<T>();
-        }
-
-        public T Top { get { return data[Count - 1]; } }
-        public T TopOrDefault { get { return Count > 0 ? data[Count - 1] : default(T); } }
-        public T Bottom { get { return data[0]; } }
-        public T BottomOrDefault { get { return Count > 0 ? data[0] : default(T); } }
-        public int Count { get { return data.Count; } }
-        public int Capacity { get { return data.Capacity; } }
-        public bool IsEmpty { get { return Count == 0; } }
-
-        public bool IsReadOnly { get { return false; } }
-
-        public void Add(T item)
-        {
-            Push(item);
-        }
-
-        public void Clear()
-        {
-            data.Clear();
-        }
-
-        public bool Contains(T item)
-        {
-            return data.Contains(item);
-        }
-
-        public void CopyTo(T[] array, int arrayIndex)
-        {
-            data.CopyTo(array, arrayIndex);
-        }
-
-        public IEnumerator<T> GetEnumerator()
-        {
-            return data.GetEnumerator();
-        }
-
-        public T ElementAt(int index)
-        {
-            return data[index];
-        }
-
-
-        public T ReverseElementAt(int offset)
-        {
-            return data[Count - 1 - offset];
-        }
-
-        public void SetTop(T value)
-        {
-            data[Count - 1] = value;
-        }
-
-        public T this[int key]
-        {
-            get { return data[key]; }
-            set { data[key] = value; }
-        }
-
-        public void Swap(int count)
-        {
-            var top = Top;
-            var bottomIndex = Count - count;
-
-            for (var i = Count - 1; i > bottomIndex; i--)
-            {
-                data[i] = data[i - 1];
-            }
-
-            data[bottomIndex] = top;
-        }
-
-        public void Yank(int index)
-        {
-            var item = ElementAt(index);
-            data.RemoveAt(index);
-            data.Add(item);
-        }
-
-        public T Pop()
-        {
-            var value = data[Count - 1];
-            data.RemoveAt(Count - 1);
-
-            return value;
-        }
-
-        public T[] Pop(int count)
-        {
-            var startIndex = Count - count;
-
-            var items = new T[count];
-            data.CopyTo(startIndex, items, 0, count);
-            Remove(count);
-
-            return items;
-        }
-
-        public void Push(T item)
-        {
-            data.Add(item);
-        }
-
-        public void Push(object[] items)
-        {
-            for (var i = 0; i < items.Length; i++)
-            {
-                data.Add((T)items[i]);
-            }
-        }
-
-        public void PushResult(int count, Func<T[], T> templateFunc)
-        {
-            var startIndex = Count - count;
-            var items = new T[count];
-
-            data.CopyTo(startIndex, items, 0, count);
-            Remove(count - 1);
-
-            data[Count - 1] = templateFunc(items);
-        }
-
-        public void Push(params T[] items)
-        {
-            for (var i = 0; i < items.Length; i++)
-            {
-                data.Add(items[i]);
-            }
-        }
-
-        public void Push(IEnumerable<T> items)
-        {
-            data.AddRange(items);
-        }
-
-        public void Insert(int index, T item)
-        {
-            data.Insert(index, item);
-        }
-
-        public void Insert(int index, params T[] items)
-        {
-            data.InsertRange(index, items);
-        }
-
-        public void Insert(int index, IEnumerable<T> items)
-        {
-            data.InsertRange(index, items);
-        }
-
-        public bool Remove(T item)
-        {
-            var index = Count - 1;
-            if (Count > 0 && data[index].Equals(item))
-            {
-                data.RemoveAt(index);
-                return true;
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        public void RemoveTop()
-        {
-            data.RemoveAt(Count - 1);
-        }
-
-        public void Remove(int count)
-        {
-            for (var i = 0; i < count; i++)
-            {
-                data.RemoveAt(Count - 1);
-            }
-        }
-
-        public void RemoveAt(int index)
-        {
-            data.RemoveAt(index);
-        }
-
-        public void RemoveAt(int index, int count)
-        {
-            data.RemoveRange(index, count);
-        }
-
-        public bool TryPop(out T item)
-        {
-            if (Count > 0)
-            {
-                item = Pop();
-                return true;
-            }
-            else
-            {
-                item = default(T);
-                return false;
-            }
-        }
-
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return (data as IEnumerable).GetEnumerator();
-        }
-
-        public override string ToString()
-        {
-            return string.Join(Delimiter, data);
-        }
-    }
+﻿namespace HeuristicLab.Algorithms.PushGP.Stack {
+  using System;
+  using System.Collections;
+  using System.Collections.Generic;
+
+  /// <summary>
+  ///     While Push's stacks are generally treated as genuine stacks---that is, inclassions take their arguments from the
+  ///     tops of
+  ///     the stacks and push their results onto the tops of the stacks---a few inclassions (like YANK and SHOVE) do allow
+  ///     direct access
+  ///     to "deep" stack elements by means of integer indices. To this extent the stacks can be used as general, random
+  ///     access memory
+  ///     classures. This is one of the features that ensures the Turing-completeness of Push (another being the arbitrary
+  ///     name/value
+  ///     bindings supported by the NAME data type and DEFINE methods; see below).
+  /// </summary>
+  /// <typeparam name="T">The item type of the collection.</typeparam>
+  public class PushGPStack<T> : IStack<T> {
+    private const string Delimiter = " ";
+
+    private readonly List<T> data;
+
+    public PushGPStack(int capacity = 0) {
+      this.data = new List<T>();
+    }
+
+    public int Capacity
+    {
+      get
+      {
+        return this.data.Capacity;
+      }
+    }
+
+    public T Top
+    {
+      get
+      {
+        return this.data[this.Count - 1];
+      }
+    }
+
+    public T TopOrDefault
+    {
+      get
+      {
+        return this.Count > 0 ? this.data[this.Count - 1] : default(T);
+      }
+    }
+
+    public T Bottom
+    {
+      get
+      {
+        return this.data[0];
+      }
+    }
+
+    public T BottomOrDefault
+    {
+      get
+      {
+        return this.Count > 0 ? this.data[0] : default(T);
+      }
+    }
+
+    public int Count
+    {
+      get
+      {
+        return this.data.Count;
+      }
+    }
+
+    public bool IsEmpty
+    {
+      get
+      {
+        return this.Count == 0;
+      }
+    }
+
+    public bool IsReadOnly
+    {
+      get
+      {
+        return false;
+      }
+    }
+
+    public void Add(T item) {
+      this.Push(item);
+    }
+
+    public void Clear() {
+      this.data.Clear();
+    }
+
+    public bool Contains(T item) {
+      return this.data.Contains(item);
+    }
+
+    public void CopyTo(T[] array, int arrayIndex) {
+      this.data.CopyTo(array, arrayIndex);
+    }
+
+    public IEnumerator<T> GetEnumerator() {
+      return this.data.GetEnumerator();
+    }
+
+    public T ElementAt(int index) {
+      return this.data[index];
+    }
+
+    public T ReverseElementAt(int offset) {
+      return this.data[this.data.Count - 1 - offset];
+    }
+
+    public void SetTop(T value) {
+      this.data[this.Count - 1] = value;
+    }
+
+    public T this[int key]
+    {
+      get
+      {
+        return this.data[key];
+      }
+      set
+      {
+        this.data[key] = value;
+      }
+    }
+
+    public void Swap(int count) {
+      var top = this.Top;
+      var bottomIndex = this.Count - count;
+
+      for (var i = this.Count - 1; i > bottomIndex; i--) this.data[i] = this.data[i - 1];
+
+      this.data[bottomIndex] = top;
+    }
+
+    public void Yank(int index) {
+      if (index == this.Count - 1) return;
+
+      var item = this.ElementAt(index);
+      this.data.RemoveAt(index);
+      this.data.Add(item);
+    }
+
+    public T Pop() {
+      var value = this.data[this.Count - 1];
+      this.data.RemoveAt(this.Count - 1);
+
+      return value;
+    }
+
+    public T[] Pop(int count) {
+      var startIndex = this.Count - count;
+
+      var items = new T[count];
+      this.data.CopyTo(startIndex, items, 0, count);
+      this.Remove(count);
+
+      return items;
+    }
+
+    public void Push(T item) {
+      this.data.Add(item);
+    }
+
+    public void PushResult(int count, Func<T[], T> templateFunc) {
+      var startIndex = this.Count - count;
+      var items = new T[count];
+
+      this.data.CopyTo(startIndex, items, 0, count);
+      this.Remove(count - 1);
+
+      this.data[this.Count - 1] = templateFunc(items);
+    }
+
+    public void Push(params T[] items) {
+      for (var i = 0; i < items.Length; i++) this.data.Add(items[i]);
+    }
+
+    public void Push(IEnumerable<T> items) {
+      this.data.AddRange(items);
+    }
+
+    public void Insert(int index, T item) {
+      this.data.Insert(index, item);
+    }
+
+    public void Insert(int index, params T[] items) {
+      this.data.InsertRange(index, items);
+    }
+
+    public void Insert(int index, IEnumerable<T> items) {
+      this.data.InsertRange(index, items);
+    }
+
+    public bool Remove(T item) {
+      var index = this.Count - 1;
+      if ((this.Count > 0) && this.data[index].Equals(item)) {
+        this.data.RemoveAt(index);
+        return true;
+      }
+      return false;
+    }
+
+    public void RemoveTop() {
+      this.data.RemoveAt(this.Count - 1);
+    }
+
+    public void Remove(int count) {
+      for (var i = 0; i < count; i++) this.data.RemoveAt(this.Count - 1);
+    }
+
+    public void RemoveAt(int index) {
+      this.data.RemoveAt(index);
+    }
+
+    public void RemoveAt(int index, int count) {
+      this.data.RemoveRange(index, count);
+    }
+
+    public bool TryPop(out T item) {
+      if (this.Count > 0) {
+        item = this.Pop();
+        return true;
+      }
+      item = default(T);
+      return false;
+    }
+
+    IEnumerator IEnumerable.GetEnumerator() {
+      return (this.data as IEnumerable).GetEnumerator();
+    }
+
+    public override string ToString() {
+      return string.Join(Delimiter, this.data);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/ArtificialDataDescriptor.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/ArtificialDataDescriptor.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/ArtificialDataDescriptor.cs	(revision 14513)
@@ -1,13 +1,15 @@
-﻿using System.Collections.Generic;
-using HeuristicLab.Problems.Instances;
+﻿namespace HeuristicLab.BenchmarkSuite
+{
+  using System.Collections.Generic;
 
-namespace HeuristicLab.BenchmarkSuite
-{
-    public abstract class ArtificialDataDescriptor : IDataDescriptor
-    {
-        public abstract string Description { get; }
-        public abstract string Name { get; }
+  using HeuristicLab.Problems.Instances;
 
-        protected abstract IEnumerable<Example> GenerateExamples();
-    }
+  public abstract class ArtificialDataDescriptor : IDataDescriptor
+  {
+    public abstract string Description { get; }
+
+    public abstract string Name { get; }
+
+    protected abstract IEnumerable<Example> GenerateExamples();
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/BenchmarkSuiteDataDescriptor.cs	(revision 14513)
@@ -1,31 +1,33 @@
-﻿using System.Collections.Generic;
-using HeuristicLab.Core;
-using HeuristicLab.Random;
+﻿namespace HeuristicLab.BenchmarkSuite
+{
+  using System.Collections.Generic;
 
-namespace HeuristicLab.BenchmarkSuite
-{
-    public abstract class BenchmarkSuiteDataDescritpor<T> : ArtificialDataDescriptor
+  using HeuristicLab.Core;
+  using HeuristicLab.Random;
+
+  public abstract class BenchmarkSuiteDataDescritpor<T> : ArtificialDataDescriptor
+  {
+    protected static IRandom rand = new FastRandom();
+
+    protected abstract IEnumerable<T> GenerateTraining();
+
+    protected abstract IEnumerable<T> GenerateTest();
+
+    protected abstract IEnumerable<Example> GenerateExamples(IEnumerable<T> trainingAndTest);
+
+    protected override IEnumerable<Example> GenerateExamples()
     {
-        protected static IRandom rand = new FastRandom();
+      var training = this.GenerateTraining();
 
-        protected abstract IEnumerable<T> GenerateTraining();
-        protected abstract IEnumerable<T> GenerateTest();
+      training = training.Shuffle(rand);
 
-        protected abstract IEnumerable<Example> GenerateExamples(IEnumerable<T> trainingAndTest);
+      var test = this.GenerateTest();
 
-        protected override IEnumerable<Example> GenerateExamples()
-        {
-            var training = GenerateTraining();
+      var all = new List<T>();
+      all.AddRange(training);
+      all.AddRange(test);
 
-            training = training.Shuffle(rand);
-
-            var test = GenerateTest();
-
-            var all = new List<T>();
-            all.AddRange(training);
-            all.AddRange(test);
-
-            return GenerateExamples(all);
-        }
+      return this.GenerateExamples(all);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Example.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Example.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Example.cs	(revision 14513)
@@ -1,8 +1,9 @@
 ﻿namespace HeuristicLab.BenchmarkSuite
 {
-    public class Example
-    {
-        public string Input { get; set; }
-        public string Output { get; set; }
-    }
+  public class Example
+  {
+    public string Input { get; set; }
+
+    public string Output { get; set; }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/HeuristicLab.BenchmarkSuite.csproj.user
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/HeuristicLab.BenchmarkSuite.csproj.user	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/HeuristicLab.BenchmarkSuite.csproj.user	(revision 14513)
@@ -0,0 +1,6 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Problems/CountOdds.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Problems/CountOdds.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Problems/CountOdds.cs	(revision 14513)
@@ -1,145 +1,142 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
+﻿namespace HeuristicLab.BenchmarkSuite.Problems
+{
+  using System.Collections.Generic;
+  using System.Linq;
 
-namespace HeuristicLab.BenchmarkSuite.Problems
-{
-    public class CountOdds : BenchmarkSuiteDataDescritpor<List<int>>
+  public class CountOdds : BenchmarkSuiteDataDescritpor<List<int>>
+  {
+    public const int MaxOdd = 999;
+
+    public const int MaxEven = 1000;
+
+    public const int MaxRandom = 1000;
+
+    public const int MinRandom = 1000;
+
+    public const int MaxVectorLength = 50;
+
+    public override string Description
     {
-        public const int MaxOdd = 999;
-        public const int MaxEven = 1000;
-        public const int MaxRandom = 1000;
-        public const int MinRandom = 1000;
-        public const int MaxVectorLength = 50;
+      get
+      {
+        return string.Empty;
+      }
+    }
 
-        public override string Description { get { return String.Empty; } }
+    public override string Name
+    {
+      get
+      {
+        return "Count Odds";
+      }
+    }
 
-        public override string Name { get { return "Count Odds"; } }
+    protected override IEnumerable<Example> GenerateExamples(IEnumerable<List<int>> inputData)
+    {
+      foreach (var input in inputData)
+        yield return
+          new Example
+            {
+              Input = string.Format("[{0}]", string.Join(", ", input)),
+              Output = input.Count(x => x % 2 == 1).ToString()
+            };
+    }
 
-        protected override IEnumerable<Example> GenerateExamples(IEnumerable<List<int>> inputData)
-        {
-            foreach (var input in inputData)
-            {
-                yield return new Example()
-                {
-                    Input = string.Format("[{0}]", string.Join(", ", input)),
-                    Output = input.Count(x => x % 2 == 1).ToString()
-                };
-            }
-        }
+    protected override IEnumerable<List<int>> GenerateTest()
+    {
+      foreach (var list in this.GetHardcodedTrainingSamples()) yield return list;
 
-        protected override IEnumerable<List<int>> GenerateTest()
-        {
-            foreach (var list in GetHardcodedTrainingSamples())
-                yield return list;
+      foreach (var list in this.GetAllOdd(100)) yield return list;
 
-            foreach (var list in GetAllOdd(n: 100))
-                yield return list;
+      foreach (var list in this.GetAllEven(100)) yield return list;
 
-            foreach (var list in GetAllEven(n: 100))
-                yield return list;
+      foreach (var list in this.GetRandom(1800)) yield return list;
+    }
 
-            foreach (var list in GetRandom(n: 1800))
-                yield return list;
-        }
+    protected override IEnumerable<List<int>> GenerateTraining()
+    {
+      foreach (var list in this.GetHardcodedTrainingSamples()) yield return list;
 
-        protected override IEnumerable<List<int>> GenerateTraining()
-        {
-            foreach (var list in GetHardcodedTrainingSamples())
-                yield return list;
+      foreach (var list in this.GetAllOdd(9)) yield return list;
 
-            foreach (var list in GetAllOdd(n: 9))
-                yield return list;
+      foreach (var list in this.GetAllEven(9)) yield return list;
 
-            foreach (var list in GetAllEven(n: 9))
-                yield return list;
+      foreach (var list in this.GetRandom(150)) yield return list;
+    }
 
-            foreach (var list in GetRandom(n: 150))
-                yield return list;
-        }
+    private IEnumerable<List<int>> GetAllOdd(int n)
+    {
+      for (var i = 0; i < n; i++)
+      {
+        var length = rand.Next(0, MaxVectorLength);
+        var vector = new List<int>(length);
 
-        private IEnumerable<List<int>> GetAllOdd(int n)
-        {
-            for (var i = 0; i < n; i++)
-            {
-                var length = rand.Next(0, MaxVectorLength);
-                var vector = new List<int>(length);
+        for (var j = 0; j < length; j++) vector.Add(rand.Next(0, MaxOdd) * 2 - MaxOdd);
 
-                for (var j = 0; j < length; j++)
-                {
-                    vector.Add(rand.Next(0, MaxOdd) * 2 - MaxOdd);
-                }
+        yield return vector;
+      }
+    }
 
-                yield return vector;
-            }
-        }
+    private IEnumerable<List<int>> GetAllEven(int n)
+    {
+      for (var i = 0; i < n; i++)
+      {
+        var length = rand.Next(0, MaxVectorLength);
+        var vector = new List<int>(length);
 
-        private IEnumerable<List<int>> GetAllEven(int n)
-        {
-            for (var i = 0; i < n; i++)
-            {
-                var length = rand.Next(0, MaxVectorLength);
-                var vector = new List<int>(length);
+        for (var j = 0; j < length; j++) vector.Add(rand.Next(0, MaxEven) * 2 - MaxEven);
 
-                for (var j = 0; j < length; j++)
-                {
-                    vector.Add(rand.Next(0, MaxEven) * 2 - MaxEven);
-                }
+        yield return vector;
+      }
+    }
 
-                yield return vector;
-            }
-        }
+    private IEnumerable<List<int>> GetRandom(int n)
+    {
+      for (var i = 0; i < n; i++)
+      {
+        var length = rand.Next(0, MaxVectorLength);
+        var vector = new List<int>(length);
 
-        private IEnumerable<List<int>> GetRandom(int n)
-        {
-            for (var i = 0; i < n; i++)
-            {
-                var length = rand.Next(0, MaxVectorLength);
-                var vector = new List<int>(length);
+        for (var j = 0; j < length; j++) vector.Add(rand.Next(MinRandom, MaxRandom));
 
-                for (var j = 0; j < length; j++)
-                {
-                    vector.Add(rand.Next(MinRandom, MaxRandom));
-                }
+        yield return vector;
+      }
+    }
 
-                yield return vector;
-            }
-        }
-
-        private IEnumerable<List<int>> GetHardcodedTrainingSamples()
-        {
-            yield return new List<int>() { };
-            yield return new List<int>() { -10 };
-            yield return new List<int>() { -9 };
-            yield return new List<int>() { -8 };
-            yield return new List<int>() { -7 };
-            yield return new List<int>() { -6 };
-            yield return new List<int>() { -5 };
-            yield return new List<int>() { -4 };
-            yield return new List<int>() { -3 };
-            yield return new List<int>() { -2 };
-            yield return new List<int>() { -1 };
-            yield return new List<int>() { -0 };
-            yield return new List<int>() { 1 };
-            yield return new List<int>() { 2 };
-            yield return new List<int>() { 3 };
-            yield return new List<int>() { 4 };
-            yield return new List<int>() { 5 };
-            yield return new List<int>() { 6 };
-            yield return new List<int>() { 7 };
-            yield return new List<int>() { 8 };
-            yield return new List<int>() { 9 };
-            yield return new List<int>() { 10 };
-            yield return new List<int>() { -947 };
-            yield return new List<int>() { -450 };
-            yield return new List<int>() { 303 };
-            yield return new List<int>() { 886 };
-            yield return new List<int>() { 0, 0 };
-            yield return new List<int>() { 0, 1 };
-            yield return new List<int>() { 7, 1 };
-            yield return new List<int>() { -9, -1 };
-            yield return new List<int>() { -11, 40 };
-            yield return new List<int>() { 944, 77 };
-        }
+    private IEnumerable<List<int>> GetHardcodedTrainingSamples()
+    {
+      yield return new List<int>();
+      yield return new List<int> { -10 };
+      yield return new List<int> { -9 };
+      yield return new List<int> { -8 };
+      yield return new List<int> { -7 };
+      yield return new List<int> { -6 };
+      yield return new List<int> { -5 };
+      yield return new List<int> { -4 };
+      yield return new List<int> { -3 };
+      yield return new List<int> { -2 };
+      yield return new List<int> { -1 };
+      yield return new List<int> { -0 };
+      yield return new List<int> { 1 };
+      yield return new List<int> { 2 };
+      yield return new List<int> { 3 };
+      yield return new List<int> { 4 };
+      yield return new List<int> { 5 };
+      yield return new List<int> { 6 };
+      yield return new List<int> { 7 };
+      yield return new List<int> { 8 };
+      yield return new List<int> { 9 };
+      yield return new List<int> { 10 };
+      yield return new List<int> { -947 };
+      yield return new List<int> { -450 };
+      yield return new List<int> { 303 };
+      yield return new List<int> { 886 };
+      yield return new List<int> { 0, 0 };
+      yield return new List<int> { 0, 1 };
+      yield return new List<int> { 7, 1 };
+      yield return new List<int> { -9, -1 };
+      yield return new List<int> { -11, 40 };
+      yield return new List<int> { 944, 77 };
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Properties/AssemblyInfo.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Properties/AssemblyInfo.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.BenchmarkSuite/Properties/AssemblyInfo.cs	(revision 14513)
@@ -1,4 +1,3 @@
 ﻿using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
@@ -6,4 +5,5 @@
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
+
 [assembly: AssemblyTitle("HeuristicLab.BenchmarkSuite")]
 [assembly: AssemblyDescription("")]
@@ -18,7 +18,9 @@
 // to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
+
 [assembly: ComVisible(false)]
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
+
 [assembly: Guid("22b5c087-cfc7-4d40-86c6-32fcf2ca921e")]
 
@@ -33,4 +35,5 @@
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj	(revision 14513)
@@ -0,0 +1,97 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.Problems.PushGP</RootNamespace>
+    <AssemblyName>HeuristicLab.Problems.PushGP</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <LangVersion>5</LangVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Plugin.cs" />
+    <Compile Include="ProgramSynthesis\PushProblem.cs" />
+    <Compile Include="ProgramSynthesis\PushEvalutator.cs" />
+    <Compile Include="ProgramSynthesis\PushProgram.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\HeuristicLab.Algorithms.PushGP\HeuristicLab.Algorithms.PushGP.csproj">
+      <Project>{368d1303-470c-4f31-91f2-0fad379daa45}</Project>
+      <Name>HeuristicLab.Algorithms.PushGP</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>"T:\BTSync\projects\svn\hl\trunk\sources\bin\HeuristicLab 3.3.exe"</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj.user
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj.user	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/HeuristicLab.Problems.PushGP.csproj.user	(revision 14513)
@@ -0,0 +1,6 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Plugin.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Plugin.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Plugin.cs	(revision 14513)
@@ -0,0 +1,35 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 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/>.
+ *
+ * Author: Patrik Kimmeswegner
+ */
+
+#endregion
+
+namespace HeuristicLab.Problems.ProgramSynthesis.PushGP {
+  using HeuristicLab.PluginInfrastructure;
+
+  [Plugin("HeuristicLab.Problems.ProgramSynthesis.PushGP", "1.0")]
+  [PluginFile("HeuristicLab.Problems.ProgramSynthesis.PushGP.dll", PluginFileType.Assembly)]
+  [PluginFile("HeuristicLab.Algorithms.PushGP.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.Random", "3.3")]
+  public class PushGpPlugin : PluginBase {
+
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushEvalutator.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushEvalutator.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushEvalutator.cs	(revision 14513)
@@ -0,0 +1,12 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.PushGP.ProgramSynthesis {
+
+  public class PushEvalutator {
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProblem.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProblem.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProblem.cs	(revision 14513)
@@ -0,0 +1,46 @@
+﻿using System;
+
+namespace HeuristicLab.Problems.PushGP.ProgramSynthesis {
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+  using HeuristicLab.Common;
+  using HeuristicLab.Core;
+  using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+  [StorableClass]
+  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 180)]
+  [Item("Push GP Problem", "")]
+  public class PushProblem : SymbolicExpressionTreeProblem {
+
+    private readonly PushGpInterpreterPool pool = new PushGpInterpreterPool(new Configuration());
+
+    // persistence
+    [StorableConstructor]
+    protected PushProblem(bool deserializing) : base(deserializing) { }
+
+    // cloning
+    protected PushProblem(PushProblem original, Cloner cloner)
+      : base(original, cloner) {
+    }
+
+    protected PushProblem() : base() { }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      throw new NotImplementedException();
+    }
+
+    public Configuration Configuration { get { return this.pool.Configuration; } }
+
+    public override bool Maximization { get { return false; } }
+
+    public override double Evaluate(ISymbolicExpressionTree tree, IRandom random) {
+      var program = tree as PushProgram;
+
+      using (var interpreter = this.pool.GetInstance()) {
+        interpreter.Interpret(program);
+      }
+
+      return 0d;
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProgram.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProgram.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/ProgramSynthesis/PushProgram.cs	(revision 14513)
@@ -0,0 +1,58 @@
+﻿using System;
+using System.Collections.Generic;
+
+namespace HeuristicLab.Problems.PushGP.ProgramSynthesis {
+  using System.Drawing;
+
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Common;
+  using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+  public class PushProgram : ExecExpandExpression, ISymbolicExpressionTree {
+    public PushProgram(Expression[] state)
+      : base(state) {
+    }
+
+    public PushProgram(ExecExpandExpression origin)
+      : base(origin) {
+    }
+
+    public object Clone() {
+      throw new NotImplementedException();
+    }
+
+    public IDeepCloneable Clone(Cloner cloner) {
+      throw new NotImplementedException();
+    }
+
+    public string ItemName { get; private set; }
+
+    public string ItemDescription { get; private set; }
+
+    public Version ItemVersion { get; private set; }
+
+    public Image ItemImage { get; private set; }
+
+    public event EventHandler ItemImageChanged;
+
+    public event EventHandler ToStringChanged;
+
+    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
+      throw new NotImplementedException();
+    }
+
+    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() {
+      throw new NotImplementedException();
+    }
+
+    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix() {
+      throw new NotImplementedException();
+    }
+
+    public ISymbolicExpressionTreeNode Root { get; set; }
+
+    public int Length { get { return this.State.Length; } }
+
+    public new int Depth { get { return base.Depth; } }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Properties/AssemblyInfo.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Properties/AssemblyInfo.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Problems.ProgramSynthesis/Properties/AssemblyInfo.cs	(revision 14513)
@@ -0,0 +1,36 @@
+﻿using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.Problems.ProgramSynthesis.PushGP")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab.Problems.ProgramSynthesis.PushGP")]
+[assembly: AssemblyCopyright("Copyright ©  2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("5c93448c-47e3-4c3f-b1d0-ee62a48c3204")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Example.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Example.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Example.cs	(revision 14513)
@@ -1,8 +1,7 @@
-﻿namespace HeuristicLab.Tests.Benchmark
-{
-    public class Example<Tin, Tout>
-    {
-        public Tin Input { get; set; }
-        public Tout Output { get; set; }
-    }
+﻿namespace HeuristicLab.Tests.Benchmark {
+  public class Example<Tin, Tout> {
+    public Tin Input { get; set; }
+
+    public Tout Output { get; set; }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs	(revision 14513)
@@ -1,35 +1,28 @@
-﻿using System.Linq;
+﻿namespace HeuristicLab.Tests.Benchmark
+{
+  using System.Linq;
 
-namespace HeuristicLab.Tests.Benchmark
-{
-    public static class ExampleConverter
+  public static class ExampleConverter
+  {
+    private const char ArrayValueSeparator = ' ';
+
+    private static readonly char[] arraySymbolTrim = { '[', ']' };
+
+    public static long Integer(string str)
     {
-        private const char ArrayValueSeparator = ' ';
+      return long.Parse(str);
+    }
 
-        private static readonly char[] arraySymbolTrim = new[] { '[', ']' };
+    public static long[] Integers(string str)
+    {
+      var values =
+        str.Trim(arraySymbolTrim).Split(ArrayValueSeparator).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
 
+      var result = new long[values.Count];
 
-        public static long Integer(string str)
-        {
-            return long.Parse(str);
-        }
+      for (var i = 0; i < result.Length; i++) result[i] = Integer(values[i]);
 
-        public static long[] Integers(string str)
-        {
-            var values = str
-                .Trim(arraySymbolTrim)
-                .Split(ArrayValueSeparator)
-                .Where(s => !string.IsNullOrWhiteSpace(s))
-                .ToList();
-
-            var result = new long[values.Count];
-
-            for (var i = 0; i < result.Length; i++)
-            {
-                result[i] = Integer(values[i]);
-            }
-
-            return result;
-        }
+      return result;
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/CountOdds.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/CountOdds.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/CountOdds.cs	(revision 14513)
@@ -1,87 +1,87 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Interpreter;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+﻿namespace HeuristicLab.Tests.Benchmark.Problem {
+  using System;
+  using System.Collections.Generic;
+  using System.Diagnostics;
+  using System.Linq;
+  using System.Threading.Tasks;
 
-namespace HeuristicLab.Tests.Benchmark.Problem
-{
-    [TestClass]
-    public class CountOdds : Problem<long[], long>
-    {
-        public const string ProblemFileName = "examples-count-odds.csv";
+  using HeuristicLab.Algorithms.PushGP.Data.Random;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Generators;
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
 
-        public CountOdds()
-        {
-            Examples = GetExamples(ProblemFileName, ExampleConverter.Integers, ExampleConverter.Integer);
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class CountOdds : Problem<long[], long> {
+    public CountOdds() {
+      this.Examples = this.GetExamples(
+        "examples-count-odds.csv",
+        ExampleConverter.Integers,
+        ExampleConverter.Integer);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Medium")]
+    [TestCategory("ProblemTest")]
+    public void RandomWalk() {
+      var maxProgramSizeLimit = 100;
+      var iterations = 4000;
+      var best = double.MaxValue;
+      var globalExecCounter = 0;
+      var lockObj = new object();
+      var lockCount = new object();
+      RandomFactory.Seed = 1337;
+
+      Expression bestProgram = null;
+      var config = new Configuration { EvalPushLimit = 500 };
+      var pool = new PushGpInterpreterPool(config);
+
+      Parallel.For(0, iterations, i => {
+
+        var execCounter = 0;
+        var program = CodeGenerator.RandomProgram(maxProgramSizeLimit);
+        var results = new List<long>();
+
+        using (var interpreter = pool.GetInstance()) {
+          foreach (var example in this.Examples) {
+            if (example.Input.Length > 0) interpreter.IntegerStack.Push(example.Input);
+
+            interpreter.Interpret(program);
+
+            if (!interpreter.IntegerStack.IsEmpty) {
+              var diff = example.Output - interpreter.IntegerStack.Top;
+              var value = diff == long.MinValue ? 10000 : Math.Min(Math.Abs(diff), 10000);
+
+              results.Add(value);
+            }
+
+            execCounter += interpreter.ExecCounter;
+            interpreter.Clear();
+          }
         }
 
-        [TestMethod]
-        [TestProperty("Time", "Medium")]
-        [TestCategory("ProblemTest")]
-        public void RandomWalk()
-        {
-            var maxProgramSizeLimit = 1000;
-            var iterations = 20000;
-            var best = double.MaxValue;
-            Expression bestProgram = null;
-            var lockObj = new object();
-            var globalExecCounter = 0;
+        lock (lockCount) {
+          globalExecCounter += execCounter;
+        }
 
+        if (results.Count == 0) return;
 
-            Parallel.For(0, iterations, async i =>
-            {
-                var interpreter = new PushGPInterpreter(new Configuration
-                {
-                    EvalPushLimit = 10000
-                });
+        var avg = results.Average();
 
-                var execCounter = 0;
-                var program = interpreter.CodeGenerator.RandomProgram(maxProgramSizeLimit);
-                var results = new List<long>();
+        if (avg >= best) return;
 
-                foreach (var example in Examples)
-                {
-                    if (example.Input.Length > 0)
-                    {
-                        interpreter.IntegerStack.Push(example.Input);
-                    }
+        lock (lockObj) {
+          if (avg < best) {
+            best = avg;
+            bestProgram = program;
+          }
+        }
+      });
 
-                    await interpreter.InterpretAsync(program);
-
-                    if (!interpreter.IntegerStack.IsEmpty)
-                    {
-                        var value = Math.Abs(example.Output - interpreter.IntegerStack.Top);
-
-                        results.Add(Math.Min(value, 1000));
-                    }
-
-                    execCounter += interpreter.ExecCounter;
-                    interpreter.Clear();
-                }
-
-                if (!results.Any())
-                    return;
-
-                var avg = results.Average();
-
-                lock (lockObj)
-                {
-                    if (avg < best)
-                    {
-                        best = avg;
-                        bestProgram = program;
-                        globalExecCounter += execCounter;
-                    }
-                }
-            });
-
-            Debug.WriteLine("Best: {0}", best);
-            Debug.WriteLine("Program: {0}", bestProgram);
-            Debug.WriteLine("ExecCounter: {0}", globalExecCounter);
-        }
+      Debug.WriteLine("Best: {0}", best);
+      Debug.WriteLine("Program: {0}", bestProgram);
+      Debug.WriteLine("ExecCounter: {0}", globalExecCounter);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/Problem.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/Problem.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/Problem/Problem.cs	(revision 14513)
@@ -1,70 +1,67 @@
-﻿using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Linq;
-using System.Reflection;
-using System.Text.RegularExpressions;
+﻿namespace HeuristicLab.Tests.Benchmark.Problem
+{
+  using System;
+  using System.Collections.Generic;
+  using System.IO;
+  using System.IO.Compression;
+  using System.Linq;
+  using System.Reflection;
+  using System.Text.RegularExpressions;
 
-namespace HeuristicLab.Tests.Benchmark.Problem
-{
-    public class Problem<Tin, Tout>
+  public class Problem<Tin, Tout>
+  {
+    public const char ExampleSeparator = ',';
+
+    public const string ArchiveFileName = "BenchmarkExamples.zip";
+
+    private static readonly string instanceArchiveName = GetResourceName(ArchiveFileName);
+
+    protected List<Example<Tin, Tout>> Examples { get; set; }
+
+    protected List<Example<Tin, Tout>> GetExamples(
+      string problemName,
+      Converter<string, Tin> inputConverter,
+      Converter<string, Tout> outputConverter)
     {
-        public const char ExampleSeparator = ',';
-        public const string ArchiveFileName = "BenchmarkExamples.zip";
+      using (var file = this.GetType().Assembly.GetManifestResourceStream(instanceArchiveName))
+      {
+        using (var archive = new ZipArchive(file, ZipArchiveMode.Read))
+        {
+          var entry = archive.Entries.SingleOrDefault(x => x.Name == problemName);
 
-        private static string instanceArchiveName = GetResourceName(ArchiveFileName);
+          using (var reader = new StreamReader(entry.Open()))
+          {
+            var examples = new List<Example<Tin, Tout>>();
 
-        protected List<Example<Tin, Tout>> Examples { get; set; }
+            // skip training headline
+            if (reader.Peek() >= 0) reader.ReadLine();
 
-        protected List<Example<Tin, Tout>> GetExamples(string problemName, Converter<string, Tin> inputConverter, Converter<string, Tout> outputConverter)
-        {
-            using (var file = GetType().Assembly.GetManifestResourceStream(instanceArchiveName))
-            using (var archive = new ZipArchive(file, ZipArchiveMode.Read))
+            while (reader.Peek() >= 0)
             {
-                var entry = archive.Entries.SingleOrDefault(x => x.Name == problemName);
+              var line = reader.ReadLine();
 
-                using (var reader = new StreamReader(entry.Open()))
-                {
-                    var examples = new List<Example<Tin, Tout>>();
+              // return
+              if (line.StartsWith("test")) break;
 
-                    // skip training headline
-                    if (reader.Peek() >= 0)
-                    {
-                        reader.ReadLine();
-                    }
+              var values = line.Split(ExampleSeparator);
 
-                    while (reader.Peek() >= 0)
-                    {
-                        var line = reader.ReadLine();
+              examples.Add(
+                new Example<Tin, Tout> { Input = inputConverter(values[0]), Output = outputConverter(values[1]) });
+            }
 
-                        // return
-                        if (line.StartsWith("test"))
-                        {
-                            break;
-                        }
+            return examples;
+          }
+        }
+      }
+    }
 
-                        var values = line.Split(ExampleSeparator);
-
-                        examples.Add(new Example<Tin, Tout>
-                        {
-                            Input = inputConverter(values[0]),
-                            Output = outputConverter(values[1])
-                        });
-                    }
-
-                    return examples;
-                }
-            }
-        }
-
-        private static string GetResourceName(string fileName)
-        {
-            return Assembly
-                .GetExecutingAssembly()
-                .GetManifestResourceNames()
-                .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success)
-                .SingleOrDefault();
-        }
+    private static string GetResourceName(string fileName)
+    {
+      return
+        Assembly.GetExecutingAssembly()
+          .GetManifestResourceNames()
+          .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success)
+          .SingleOrDefault();
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 14513)
@@ -27,4 +27,5 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <LangVersion>5</LangVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -74,5 +75,6 @@
     <Compile Include="Interpreter\Expressions\CodeExpressionTests.cs" />
     <Compile Include="Interpreter\Expressions\IntegerExpressionTests.cs" />
-    <Compile Include="Interpreter\InterpreterTest.cs" />
+    <Compile Include="Interpreter\Expressions\StandardTests.cs" />
+    <Compile Include="Interpreter\ExpressionTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
@@ -86,5 +88,7 @@
     <EmbeddedResource Include="Benchmark\Data\BenchmarkExamples.zip" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <Folder Include="Interpreter\Generator\" />
+  </ItemGroup>
   <Choose>
     <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj.user
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj.user	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj.user	(revision 14513)
@@ -2,5 +2,5 @@
 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <ProjectView>ProjectFiles</ProjectView>
+    <ProjectView>ShowAllFiles</ProjectView>
   </PropertyGroup>
 </Project>
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/ExpressionTest.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/ExpressionTest.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/ExpressionTest.cs	(revision 14513)
@@ -0,0 +1,38 @@
+﻿namespace HeuristicLab.Tests.Interpreter
+{
+  using HeuristicLab.Algorithms.PushGP.Interpreter;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  public class ExpressionTest
+  {
+    protected PushGpInterpreter interpreter;
+
+    [TestInitialize]
+    public void BeforeTest()
+    {
+      this.interpreter = new PushGpInterpreter(new Configuration { TopLevelPushCode = false });
+    }
+
+    protected void TestStackCounts(
+      int? execStack = 0,
+      int? codeStack = 0,
+      int? nameStack = 0,
+      int? booleanStack = 0,
+      int? floatStack = 0,
+      int? integerStack = 0)
+    {
+      if (execStack.HasValue) Assert.AreEqual(execStack, this.interpreter.ExecStack.Count);
+
+      if (codeStack.HasValue) Assert.AreEqual(codeStack, this.interpreter.CodeStack.Count);
+
+      if (nameStack.HasValue) Assert.AreEqual(nameStack, this.interpreter.NameStack.Count);
+
+      if (booleanStack.HasValue) Assert.AreEqual(booleanStack, this.interpreter.BooleanStack.Count);
+
+      if (floatStack.HasValue) Assert.AreEqual(floatStack, this.interpreter.FloatStack.Count);
+
+      if (integerStack.HasValue) Assert.AreEqual(integerStack, this.interpreter.IntegerStack.Count);
+    }
+  }
+}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/BooleanExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/BooleanExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/BooleanExpressionTests.cs	(revision 14513)
@@ -1,145 +1,156 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-    [TestClass]
-    public class BooleanExpressionTests : CommonTests<bool>
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class BooleanExpressionTests : CommonTests<bool>
+  {
+    protected override string TypeName
     {
-        protected override string TypeName { get { return "BOOLEAN"; } }
-        protected override IStack<bool> Stack { get { return interpreter.BooleanStack; } }
+      get
+      {
+        return "BOOLEAN";
+      }
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestAnd()
-        {
-            interpreter.BooleanStack.Push(true, false);
-            interpreter.Interpret(new BooleanAndExpression());
+    protected override IStack<bool> Stack
+    {
+      get
+      {
+        return this.interpreter.BooleanStack;
+      }
+    }
 
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestAnd()
+    {
+      this.interpreter.BooleanStack.Push(true, false);
+      this.interpreter.Interpret(new BooleanAndExpression());
 
-            TestStackCounts(booleanStack: 1);
-        }
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestAndWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("AND", 1);
-        }
+      this.TestStackCounts(booleanStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestOr()
-        {
-            interpreter.BooleanStack.Push(true, false);
-            interpreter.Interpret(new BooleanOrExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestAndWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("AND", 1);
+    }
 
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestOr()
+    {
+      this.interpreter.BooleanStack.Push(true, false);
+      this.interpreter.Interpret(new BooleanOrExpression());
 
-            TestStackCounts(booleanStack: 1);
-        }
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestOrWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("OR", 1);
-        }
+      this.TestStackCounts(booleanStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestNot()
-        {
-            interpreter.BooleanStack.Push(true);
-            interpreter.Interpret(new BooleanNotExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestOrWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("OR", 1);
+    }
 
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestNot()
+    {
+      this.interpreter.BooleanStack.Push(true);
+      this.interpreter.Interpret(new BooleanNotExpression());
 
-            TestStackCounts(booleanStack: 1);
-        }
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestNotWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("NOT");
-        }
+      this.TestStackCounts(booleanStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestFromFloat()
-        {
-            interpreter.FloatStack.Push(2.0);
-            interpreter.Interpret(new BooleanFromFloatExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestNotWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("NOT");
+    }
 
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestFromFloat()
+    {
+      this.interpreter.FloatStack.Push(2.0);
+      this.interpreter.Interpret(new BooleanFromFloatExpression());
 
-            TestStackCounts(booleanStack: 1);
-        }
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestFromFloatWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMFLOAT");
-        }
+      this.TestStackCounts(booleanStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestFromInteger()
-        {
-            interpreter.IntegerStack.Push(2);
-            interpreter.Interpret(new BooleanFromIntegerExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestFromFloatWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMFLOAT");
+    }
 
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestFromInteger()
+    {
+      this.interpreter.IntegerStack.Push(2);
+      this.interpreter.Interpret(new BooleanFromIntegerExpression());
 
-            TestStackCounts(booleanStack: 1);
-        }
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("BooleanExpressionTest")]
-        public void TestFromIntegerWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMINTEGER");
-        }
+      this.TestStackCounts(booleanStack: 1);
+    }
 
-        protected override bool[] GetValues(int count)
-        {
-            var values = new bool[count];
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("BooleanExpressionTest")]
+    public void TestFromIntegerWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMINTEGER");
+    }
 
-            for (var i = 0; i < count; i++)
-            {
-                values[i] = i % 2 == 0;
-            }
+    protected override bool[] GetValues(int count)
+    {
+      var values = new bool[count];
 
-            return values;
-        }
+      for (var i = 0; i < count; i++) values[i] = i % 2 == 0;
 
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(booleanStack: null);
-        }
+      return values;
     }
+
+    protected override void CheckOtherStacksAreEmpty()
+    {
+      this.TestStackCounts(booleanStack: null);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CodeExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CodeExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CodeExpressionTests.cs	(revision 14513)
@@ -1,1116 +1,1066 @@
-﻿using HeuristicLab.Algorithms.PushGP;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-    [TestClass]
-    public class CodeExpressionTests : CommonTests<Expression>
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions {
+  using HeuristicLab.Algorithms.PushGP;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Parser;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class CodeExpressionTests : CommonTests<Expression> {
+    protected override string TypeName
     {
-        protected override string TypeName { get { return "CODE"; } }
-        protected override IStack<Expression> Stack { get { return interpreter.CodeStack; } }
-
-        private CodeGenerator cg;
-        public CodeExpressionTests()
-        {
-            cg = new CodeGenerator(interpreter);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAppendLists()
-        {
-            var first = Parser.Parse("( A )");
-            var second = Parser.Parse("( B )");
-            var result = Parser.Parse("( A B )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeAppendExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAppendListAndLiteral()
-        {
-            var first = Parser.Parse("( A )");
-            var second = Parser.Parse("5");
-            var result = Parser.Parse("( A 5 )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeAppendExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAppendLiterals()
-        {
-            var first = Parser.Parse("4");
-            var second = Parser.Parse("5");
-            var result = Parser.Parse("( 4 5 )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeAppendExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAtomList()
-        {
-            var first = Parser.Parse("( A )");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeAtomExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAtomLiteral()
-        {
-            var first = Parser.Parse("5");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeAtomExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestAtomSingleInstruction()
-        {
-            var first = Parser.Parse("INTEGER.+");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeAtomExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestCarList()
-        {
-            var first = Parser.Parse("( A B C )");
-            var result = Parser.Parse("A");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeCarExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestCarNoList()
-        {
-            var first = Parser.Parse("5");
-            var result = Parser.Parse("5");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeCarExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestCdrList()
-        {
-            var first = Parser.Parse("( A B C )");
-            var result = Parser.Parse("( B C )");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestCdrNoList()
-        {
-            var first = Parser.Parse("5");
-            var result = Parser.Parse("( )");
-
-            interpreter.CodeStack.Push(first);
-            interpreter.Interpret(new CodeCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestCons()
-        {
-            var first = Parser.Parse("( B C )");
-            var second = Parser.Parse("A");
-            var result = Parser.Parse("( A B C )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeConsExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestContainsTrue()
-        {
-            var first = Parser.Parse("A");
-            var second = Parser.Parse("( A B C )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeContainsExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestContainsFalse()
-        {
-            var first = Parser.Parse("D");
-            var second = Parser.Parse("( A B C )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeContainsExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestContainer()
-        {
-            var first = Parser.Parse("( A )");
-            var second = Parser.Parse("( B ( C ( A ) ) ( D ( A ) ) )");
-            var result = Parser.Parse("( C ( A ) )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeContainerExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDefinition()
-        {
-            var code = Parser.Parse("( A )");
-
-            interpreter.CustomExpressions.Add("Test", code);
-            interpreter.NameStack.Push("Test");
-
-            interpreter.Interpret(new CodeDefinitionExpression());
-
-            Assert.AreEqual(code, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDefinitionWithoutMatchingName()
-        {
-            var code = Parser.Parse("( A )");
-            var program = new CodeDefinitionExpression();
-
-            interpreter.CustomExpressions.Add("Test1", code);
-            interpreter.NameStack.Push("Test2");
-            interpreter.Interpret(program);
-
-            TestStackCounts(nameStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDiscrepancy()
-        {
-            var first = Parser.Parse("( A B )");
-            var second = Parser.Parse("( B C )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeDiscrepancyExpression());
-
-            Assert.AreEqual(2, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDiscrepancyAllEqual()
-        {
-            var first = Parser.Parse("( A B )");
-            var second = Parser.Parse("( B A )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeDiscrepancyExpression());
-
-            Assert.AreEqual(0, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDiscrepancyComplex()
-        {
-            var first = Parser.Parse("( A A B C D A )");
-            var second = Parser.Parse("( A A B D E )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeDiscrepancyExpression());
-
-            Assert.AreEqual(3, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDiscrepancWithLists()
-        {
-            var first = Parser.Parse("( ( A ) A ( B ) C D A )");
-            var second = Parser.Parse("( A ( A ) B D E )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeDiscrepancyExpression());
-
-            Assert.AreEqual(5, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDo()
-        {
-            var prog = Parser.Parse("( 10 )");
-
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoExpression());
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoX()
-        {
-            var prog = Parser.Parse("( 10 )");
-
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoXExpression());
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoCount()
-        {
-            var prog = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoCountExpression());
-
-            Assert.AreEqual(6, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoCountWithNegativeCounter()
-        {
-            var prog = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(-1);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoCountExpression());
-
-            Assert.AreEqual(-1, interpreter.IntegerStack.Top);
-            TestStackCounts(codeStack: 1, integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoRange()
-        {
-            var prog = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(3, 5);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoRangeExpression());
-
-            Assert.AreEqual(12, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoRangeWithEqualIndecators()
-        {
-            var prog = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(3, 3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoRangeExpression());
-
-            Assert.AreEqual(3, interpreter.IntegerStack.Top);
-            TestStackCounts(codeStack: 1, integerStack: 2);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoRangeWithNegativeIndecators()
-        {
-            var prog = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(-3, -5);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoRangeExpression());
-
-            Assert.AreEqual(-12, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoTimes()
-        {
-            var prog = Parser.Parse("( INTEGER.DUP INTEGER.+ )");
-
-            interpreter.IntegerStack.Push(2, 3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoTimesExpression());
-
-            Assert.AreEqual(32, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestDoTimesWithNegativeCounter()
-        {
-            var prog = Parser.Parse("( INTEGER.DUP INTEGER.+ )");
-
-            interpreter.IntegerStack.Push(2, -3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeDoTimesExpression());
-
-            Assert.AreEqual(-3, interpreter.IntegerStack.Top);
-            TestStackCounts(codeStack: 1, integerStack: 2);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNestedDoRange()
-        {
-            interpreter.Interpret("( 0 2 CODE.QUOTE ( 1 INTEGER.+ 0 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*RANGE INTEGER.+ ) CODE.DO*RANGE )");
-
-            Assert.AreEqual(144, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNestedDoCount()
-        {
-            interpreter.Interpret("( 2 CODE.QUOTE ( 1 INTEGER.+ 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*COUNT INTEGER.+ ) CODE.DO*COUNT )");
-
-            Assert.AreEqual(144, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNestedDoTimes()
-        {
-            interpreter.Interpret("( 3 CODE.QUOTE ( 2 3 CODE.QUOTE ( 2 INTEGER.* ) CODE.DO*TIMES INTEGER.+ ) CODE.DO*TIMES )");
-
-            Assert.AreEqual(128, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestExtract()
-        {
-            var prog = Parser.Parse("( A ( B C ( D ) E ) F )");
-            var result = Parser.Parse("( D )");
-
-            interpreter.IntegerStack.Push(5);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeExtractExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestExtractInteger()
-        {
-            var prog = Parser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
-            var result = Parser.Parse("5");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeExtractExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestExtractFloat()
-        {
-            var prog = Parser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
-            var result = Parser.Parse("4.2");
-
-            interpreter.IntegerStack.Push(6);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeExtractExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestExtractBoolean()
-        {
-            var prog = Parser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
-            var result = Parser.Parse("FALSE");
-
-            interpreter.IntegerStack.Push(8);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeExtractExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestExtractInstruction()
-        {
-            var prog = Parser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
-            var result = Parser.Parse("INTEGER.+");
-
-            interpreter.IntegerStack.Push(7);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeExtractExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestFromBoolean()
-        {
-            var result = Parser.Parse("FALSE");
-            interpreter.BooleanStack.Push(false);
-            interpreter.Interpret(new CodeFromBooleanExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestFromFloat()
-        {
-            var result = Parser.Parse("4.1");
-            interpreter.FloatStack.Push(4.1);
-            interpreter.Interpret(new CodeFromFloatExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestFromInteger()
-        {
-            var result = Parser.Parse("4");
-            interpreter.IntegerStack.Push(4);
-            interpreter.Interpret(new CodeFromIntegerExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestFromName()
-        {
-            var result = Parser.Parse("A");
-            interpreter.NameStack.Push("A");
-            interpreter.Interpret(new CodeFromNameExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestIfTrue()
-        {
-            var first = Parser.Parse("FALSCH");
-            var second = Parser.Parse("WAHR");
-
-            interpreter.BooleanStack.Push(true);
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeIfExpression());
-
-            Assert.AreEqual("WAHR", interpreter.NameStack.Top);
-            TestStackCounts(nameStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestIfFalse()
-        {
-            var first = Parser.Parse("FALSCH");
-            var second = Parser.Parse("WAHR");
-
-            interpreter.BooleanStack.Push(false);
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeIfExpression());
-
-            Assert.AreEqual("FALSCH", interpreter.NameStack.Top);
-            TestStackCounts(nameStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestInsert()
-        {
-            var first = Parser.Parse("( A ( B ) C D )");
-            var second = Parser.Parse("( E )");
-            var result = Parser.Parse("( A ( B ) ( E ) D )");
-
-            interpreter.IntegerStack.Push(2);
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeInsertExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestInsertWithNegativeN()
-        {
-            var first = Parser.Parse("( A ( B ) C D )");
-            var second = Parser.Parse("( E )");
-            var result = Parser.Parse("( A ( B ) ( E ) D )");
-
-            interpreter.IntegerStack.Push(-2);
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeInsertExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestInsertWithTooBigN()
-        {
-            var first = Parser.Parse("( A ( B ) C D )");
-            var second = Parser.Parse("( E )");
-            var result = Parser.Parse("( A ( B ) ( E ) D )");
-
-            interpreter.IntegerStack.Push(10);
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeInsertExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestList()
-        {
-            var first = Parser.Parse("A");
-            var second = Parser.Parse("( B )");
-            var result = Parser.Parse("( A ( B ) )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeListExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestMemberTrue()
-        {
-            var first = Parser.Parse("( A B ( B ) C ");
-            var second = Parser.Parse("( B )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeMemberExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestMemberFalse()
-        {
-            var first = Parser.Parse("( A B C ");
-            var second = Parser.Parse("( B )");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeMemberExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestMemberIfNoList()
-        {
-            var first = Parser.Parse("B");
-            var second = Parser.Parse("B");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodeMemberExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNoop()
-        {
-            interpreter.Interpret(new CodeNoopExpression());
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthIfNoList()
-        {
-            var prog = Parser.Parse("A");
-            var result = Parser.Parse("A");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthIfEmpty()
-        {
-            var prog = Parser.Parse("( )");
-            var result = Parser.Parse("( )");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNth()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthWithTooBigN()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(13);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthWithNegativeN()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(-3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthCdr()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(2);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthCdrWithTooBigN()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(10);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthCdrWithNegativeN()
-        {
-            var prog = Parser.Parse("( A B C D E )");
-            var result = Parser.Parse("D");
-
-            interpreter.IntegerStack.Push(-2);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthCdrIfEmpty()
-        {
-            var prog = Parser.Parse("( )");
-            var result = Parser.Parse("( )");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNthCdrIfNoList()
-        {
-            var prog = Parser.Parse("A");
-            var result = Parser.Parse("A");
-
-            interpreter.IntegerStack.Push(3);
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNthCdrExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNullTrue()
-        {
-            var prog = Parser.Parse("( )");
-
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNullExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestNullFalse()
-        {
-            var prog = Parser.Parse("A");
-
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeNullExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestPosition()
-        {
-            var first = Parser.Parse("( A B C D )");
-            var second = Parser.Parse("C");
-
-            interpreter.CodeStack.Push(second, first);
-            interpreter.Interpret(new CodePositionExpression());
-
-            Assert.AreEqual(2, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestQuote()
-        {
-            var result = Parser.Parse("A");
-
-            interpreter.Interpret("( CODE.QUOTE A )");
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestSize()
-        {
-            var prog = Parser.Parse("( A ( B ( C ) ) ( D ) INTEGER.+ )");
-
-            interpreter.CodeStack.Push(prog);
-            interpreter.Interpret(new CodeSizeExpression());
-
-            Assert.AreEqual(4, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CodeExpressionTest")]
-        public void TestSubstitude()
-        {
-            var first = Parser.Parse("( A B C D A B C D )");
-            var second = Parser.Parse("E");
-            var third = Parser.Parse("A");
-            var result = Parser.Parse("( E B C D E B C D )");
-
-            interpreter.CodeStack.Push(third, second, first);
-            interpreter.Interpret(new CodeSubstitutionExpression());
-
-            Assert.AreEqual(result, interpreter.CodeStack.Top);
-            CheckOtherStacksAreEmpty();
-        }
-
-        protected override Expression[] GetValues(int count)
-        {
-            var values = new Expression[count];
-
-            for (var i = 0; i < count; i++)
-            {
-                values[i] = new CodeNoopExpression();
-            }
-
-            return values;
-        }
-
-        protected override Expression[] Get2Different()
-        {
-            return new Expression[]
-            {
-                new CodeNoopExpression(),
-                new CodeNullExpression()
-            };
-        }
-
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(codeStack: null);
-        }
-    }
+      get
+      {
+        return "CODE";
+      }
+    }
+
+    protected override IStack<Expression> Stack
+    {
+      get
+      {
+        return this.interpreter.CodeStack;
+      }
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAppendLists() {
+      var first = PushGPParser.Parse("( A )");
+      var second = PushGPParser.Parse("( B )");
+      var result = PushGPParser.Parse("( A B )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeAppendExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAppendListAndLiteral() {
+      var first = PushGPParser.Parse("( A )");
+      var second = PushGPParser.Parse("5");
+      var result = PushGPParser.Parse("( A 5 )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeAppendExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAppendLiterals() {
+      var first = PushGPParser.Parse("4");
+      var second = PushGPParser.Parse("5");
+      var result = PushGPParser.Parse("( 4 5 )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeAppendExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDuplicateList() {
+      var list = PushGPParser.Parse("( A B C )");
+      var result = PushGPParser.Parse("( A B C )");
+
+      this.interpreter.CodeStack.Push(list);
+      this.interpreter.Interpret(new CodeDuplicateExpression());
+
+      Assert.AreEqual(this.Stack.Count, 2);
+      Assert.AreEqual(this.Stack[0], list);
+      Assert.AreEqual(this.Stack[1], result);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAtomList() {
+      var first = PushGPParser.Parse("( A )");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeAtomExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAtomLiteral() {
+      var first = PushGPParser.Parse("5");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeAtomExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestAtomSingleInstruction() {
+      var first = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeAtomExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestCarList() {
+      var first = PushGPParser.Parse("( A B C )");
+      var result = PushGPParser.Parse("A");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeCarExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestCarNoList() {
+      var first = PushGPParser.Parse("5");
+      var result = PushGPParser.Parse("5");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeCarExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestCdrList() {
+      var first = PushGPParser.Parse("( A B C )");
+      var result = PushGPParser.Parse("( B C )");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestCdrNoList() {
+      var first = PushGPParser.Parse("5");
+      var result = PushGPParser.Parse("( )");
+
+      this.interpreter.CodeStack.Push(first);
+      this.interpreter.Interpret(new CodeCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestCons() {
+      var first = PushGPParser.Parse("( B C )");
+      var second = PushGPParser.Parse("A");
+      var result = PushGPParser.Parse("( A B C )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeConsExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestContainsTrue() {
+      var first = PushGPParser.Parse("A");
+      var second = PushGPParser.Parse("( A B C )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeContainsExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestContainsFalse() {
+      var first = PushGPParser.Parse("D");
+      var second = PushGPParser.Parse("( A B C )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeContainsExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestContainer() {
+      var first = PushGPParser.Parse("( A )");
+      var second = PushGPParser.Parse("( B ( C ( A ) ) ( D ( A ) ) )");
+      var result = PushGPParser.Parse("( C ( A ) )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeContainerExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDefinition() {
+      var code = PushGPParser.Parse("( A )");
+
+      this.interpreter.CustomExpressions.Add("Test", code);
+      this.interpreter.NameStack.Push("Test");
+
+      this.interpreter.Interpret(new CodeDefinitionExpression());
+
+      Assert.AreEqual(code, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDefinitionWithoutMatchingName() {
+      var code = PushGPParser.Parse("( A )");
+      var program = new CodeDefinitionExpression();
+
+      this.interpreter.CustomExpressions.Add("Test1", code);
+      this.interpreter.NameStack.Push("Test2");
+      this.interpreter.Interpret(program);
+
+      this.TestStackCounts(nameStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDiscrepancy() {
+      var first = PushGPParser.Parse("( A B )");
+      var second = PushGPParser.Parse("( B C )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeDiscrepancyExpression());
+
+      Assert.AreEqual(2, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDiscrepancyAllEqual() {
+      var first = PushGPParser.Parse("( A B )");
+      var second = PushGPParser.Parse("( B A )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeDiscrepancyExpression());
+
+      Assert.AreEqual(0, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDiscrepancyComplex() {
+      var first = PushGPParser.Parse("( A A B C D A )");
+      var second = PushGPParser.Parse("( A A B D E )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeDiscrepancyExpression());
+
+      Assert.AreEqual(3, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDiscrepancWithLists() {
+      var first = PushGPParser.Parse("( ( A ) A ( B ) C D A )");
+      var second = PushGPParser.Parse("( A ( A ) B D E )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeDiscrepancyExpression());
+
+      Assert.AreEqual(5, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDo() {
+      var prog = PushGPParser.Parse("( 10 )");
+
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoExpression());
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoX() {
+      var prog = PushGPParser.Parse("( 10 )");
+
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoXExpression());
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoCount() {
+      var prog = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoCountExpression());
+
+      Assert.AreEqual(6, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoCountWithNegativeCounter() {
+      var prog = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(-1);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoCountExpression());
+
+      Assert.AreEqual(-1, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(codeStack: 1, integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoRange() {
+      var prog = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(3, 5);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoRangeExpression());
+
+      Assert.AreEqual(12, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoRangeWithEqualIndecators() {
+      var prog = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(3, 3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoRangeExpression());
+
+      Assert.AreEqual(3, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(codeStack: 1, integerStack: 2);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoRangeWithNegativeIndecators() {
+      var prog = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(-3, -5);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoRangeExpression());
+
+      Assert.AreEqual(-12, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoTimes() {
+      var prog = PushGPParser.Parse("( INTEGER.DUP INTEGER.+ )");
+
+      this.interpreter.IntegerStack.Push(2, 3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoTimesExpression());
+
+      Assert.AreEqual(32, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestDoTimesWithNegativeCounter() {
+      var prog = PushGPParser.Parse("( INTEGER.DUP INTEGER.+ )");
+
+      this.interpreter.IntegerStack.Push(2, -3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeDoTimesExpression());
+
+      Assert.AreEqual(-3, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(codeStack: 1, integerStack: 2);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNestedDoRange() {
+      this.interpreter.Interpret(
+        "( 0 2 CODE.QUOTE ( 1 INTEGER.+ 0 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*RANGE INTEGER.+ ) CODE.DO*RANGE )");
+
+      Assert.AreEqual(144, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNestedDoCount() {
+      this.interpreter.Interpret(
+        "( 2 CODE.QUOTE ( 1 INTEGER.+ 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*COUNT INTEGER.+ ) CODE.DO*COUNT )");
+
+      Assert.AreEqual(144, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNestedDoTimes() {
+      this.interpreter.Interpret(
+        "( 3 CODE.QUOTE ( 2 3 CODE.QUOTE ( 2 INTEGER.* ) CODE.DO*TIMES INTEGER.+ ) CODE.DO*TIMES )");
+
+      Assert.AreEqual(128, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestExtract() {
+      var prog = PushGPParser.Parse("( A ( B C ( D ) E ) F G H I J ( K ) L )");
+      var result = PushGPParser.Parse("( D )");
+
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeExtractExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestExtractInteger() {
+      var prog = PushGPParser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
+      var result = PushGPParser.Parse("5");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeExtractExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestExtractFloat() {
+      var prog = PushGPParser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
+      var result = PushGPParser.Parse("4.2");
+
+      this.interpreter.IntegerStack.Push(6);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeExtractExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestExtractBoolean() {
+      var prog = PushGPParser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
+      var result = PushGPParser.Parse("FALSE");
+
+      this.interpreter.IntegerStack.Push(8);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeExtractExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestExtractInstruction() {
+      var prog = PushGPParser.Parse("( A ( 5 C ( 4.2 ) INTEGER.+ ) FALSE )");
+      var result = PushGPParser.Parse("INTEGER.+");
+
+      this.interpreter.IntegerStack.Push(7);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeExtractExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestFromBoolean() {
+      var result = PushGPParser.Parse("FALSE");
+      this.interpreter.BooleanStack.Push(false);
+      this.interpreter.Interpret(new CodeFromBooleanExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestFromFloat() {
+      var result = PushGPParser.Parse("4.1");
+      this.interpreter.FloatStack.Push(4.1);
+      this.interpreter.Interpret(new CodeFromFloatExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestFromInteger() {
+      var result = PushGPParser.Parse("4");
+      this.interpreter.IntegerStack.Push(4);
+      this.interpreter.Interpret(new CodeFromIntegerExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestFromName() {
+      var result = PushGPParser.Parse("A");
+      this.interpreter.NameStack.Push("A");
+      this.interpreter.Interpret(new CodeFromNameExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestIfTrue() {
+      var first = PushGPParser.Parse("FALSCH");
+      var second = PushGPParser.Parse("WAHR");
+
+      this.interpreter.BooleanStack.Push(true);
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeIfExpression());
+
+      Assert.AreEqual("WAHR", this.interpreter.NameStack.Top);
+      this.TestStackCounts(nameStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestIfFalse() {
+      var first = PushGPParser.Parse("FALSCH");
+      var second = PushGPParser.Parse("WAHR");
+
+      this.interpreter.BooleanStack.Push(false);
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeIfExpression());
+
+      Assert.AreEqual("FALSCH", this.interpreter.NameStack.Top);
+      this.TestStackCounts(nameStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestInsert() {
+      var first = PushGPParser.Parse("( A ( B ) C D )");
+      var second = PushGPParser.Parse("( E )");
+      var result = PushGPParser.Parse("( A ( B ) ( E ) D )");
+
+      this.interpreter.IntegerStack.Push(2);
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeInsertExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestInsertWithNegativeN() {
+      var first = PushGPParser.Parse("( A ( B ) C D )");
+      var second = PushGPParser.Parse("( E )");
+      var result = PushGPParser.Parse("( A ( B ) ( E ) D )");
+
+      this.interpreter.IntegerStack.Push(-2);
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeInsertExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestInsertWithTooBigN() {
+      var first = PushGPParser.Parse("( A ( B ) C D )");
+      var second = PushGPParser.Parse("( E )");
+      var result = PushGPParser.Parse("( A ( B ) ( E ) D )");
+
+      this.interpreter.IntegerStack.Push(10);
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeInsertExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestList() {
+      var first = PushGPParser.Parse("A");
+      var second = PushGPParser.Parse("( B )");
+      var result = PushGPParser.Parse("( A ( B ) )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeListExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestMemberTrue() {
+      var first = PushGPParser.Parse("( A B ( B ) C ");
+      var second = PushGPParser.Parse("( B )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeMemberExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestMemberFalse() {
+      var first = PushGPParser.Parse("( A B C ");
+      var second = PushGPParser.Parse("( B )");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeMemberExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestMemberIfNoList() {
+      var first = PushGPParser.Parse("B");
+      var second = PushGPParser.Parse("B");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodeMemberExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNoop() {
+      this.interpreter.Interpret(new CodeNoopExpression());
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthIfNoList() {
+      var prog = PushGPParser.Parse("A");
+      var result = PushGPParser.Parse("A");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthIfEmpty() {
+      var prog = PushGPParser.Parse("( )");
+      var result = PushGPParser.Parse("( )");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNth() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthWithTooBigN() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(13);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthWithNegativeN() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(-3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthCdr() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(2);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthCdrWithTooBigN() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(10);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthCdrWithNegativeN() {
+      var prog = PushGPParser.Parse("( A B C D E )");
+      var result = PushGPParser.Parse("D");
+
+      this.interpreter.IntegerStack.Push(-2);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthCdrIfEmpty() {
+      var prog = PushGPParser.Parse("( )");
+      var result = PushGPParser.Parse("( )");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNthCdrIfNoList() {
+      var prog = PushGPParser.Parse("A");
+      var result = PushGPParser.Parse("A");
+
+      this.interpreter.IntegerStack.Push(3);
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNthCdrExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNullTrue() {
+      var prog = PushGPParser.Parse("( )");
+
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNullExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestNullFalse() {
+      var prog = PushGPParser.Parse("A");
+
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeNullExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestPosition() {
+      var first = PushGPParser.Parse("( A B C D )");
+      var second = PushGPParser.Parse("C");
+
+      this.interpreter.CodeStack.Push(second, first);
+      this.interpreter.Interpret(new CodePositionExpression());
+
+      Assert.AreEqual(2, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestQuote() {
+      var result = PushGPParser.Parse("A");
+
+      this.interpreter.Interpret("( CODE.QUOTE A )");
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestSize() {
+      var prog = PushGPParser.Parse("( A ( B ( C ) ) ( D ) INTEGER.+ )");
+
+      this.interpreter.CodeStack.Push(prog);
+      this.interpreter.Interpret(new CodeSizeExpression());
+
+      Assert.AreEqual(4, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CodeExpressionTest")]
+    public void TestSubstitude() {
+      var first = PushGPParser.Parse("( A B C D A B C D )");
+      var second = PushGPParser.Parse("E");
+      var third = PushGPParser.Parse("A");
+      var result = PushGPParser.Parse("( E B C D E B C D )");
+
+      this.interpreter.CodeStack.Push(third, second, first);
+      this.interpreter.Interpret(new CodeSubstitutionExpression());
+
+      Assert.AreEqual(result, this.interpreter.CodeStack.Top);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    protected override Expression[] GetValues(int count) {
+      var values = new Expression[count];
+
+      for (var i = 0; i < count; i++) values[i] = new CodeNoopExpression();
+
+      return values;
+    }
+
+    protected override Expression[] Get2Different() {
+      return new Expression[] { new CodeNoopExpression(), new CodeNullExpression() };
+    }
+
+    protected override void CheckOtherStacksAreEmpty() {
+      this.TestStackCounts(codeStack: null);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CommonTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CommonTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/CommonTests.cs	(revision 14513)
@@ -1,328 +1,301 @@
-﻿using HeuristicLab.Algorithms.PushGP;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-
-    public abstract class CommonTests<T> : ExpressionTest
-    {
-        protected const string FullInstructionNameFormat = "{0}.{1}";
-        protected abstract string TypeName { get; }
-        protected abstract IStack<T> Stack { get; }
-
-        protected abstract T[] GetValues(int count);
-
-        protected virtual T[] Get2Different()
-        {
-            return GetValues(2);
-        }
-
-        protected virtual void Test(Expression expression)
-        {
-            interpreter.Interpret(expression);
-        }
-
-        protected abstract void CheckOtherStacksAreEmpty();
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestEqualsTrue()
-        {
-            var values = GetValues(1);
-            var merged = new[] { values[0], values[0] };
-
-            Stack.Push(merged);
-
-            var isBooleanStack = interpreter.BooleanStack.Count == 2;
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".="));
-
-            if (isBooleanStack)
-            {
-                Assert.AreEqual(1, Stack.Count);
-            }
-            else
-            {
-                Assert.AreEqual(0, Stack.Count);
-            }
-
-            Assert.IsTrue(interpreter.BooleanStack.Top);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestEqualsFalse()
-        {
-            var values = Get2Different();
-            Stack.Push(values);
-            var isBooleanStack = interpreter.BooleanStack.Count == 2;
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".="));
-
-            if (isBooleanStack)
-            {
-                Assert.AreEqual(1, Stack.Count);
-            }
-            else
-            {
-                Assert.AreEqual(0, Stack.Count);
-            }
-
-            Assert.IsFalse(interpreter.BooleanStack.Top);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestEqualsWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("=", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestPop()
-        {
-            var values = GetValues(2);
-            Stack.Push(values);
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".POP"));
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestSwap()
-        {
-            var values = GetValues(3);
-            Stack.Push(values);
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".SWAP"));
-
-            Assert.AreEqual(values[0], Stack[0]);
-            Assert.AreEqual(values[2], Stack[1]);
-            Assert.AreEqual(values[1], Stack[2]);
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestSwapWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("SWAP", 1);
-        }
-
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestRotate()
-        {
-            var values = GetValues(4);
-            Stack.Push(values);
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".ROT"));
-
-            Assert.AreEqual(values[0], Stack[0]);
-            Assert.AreEqual(values[3], Stack[1]);
-            Assert.AreEqual(values[1], Stack[2]);
-            Assert.AreEqual(values[2], Stack[3]);
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestRotateWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("ROT", 2);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestShove()
-        {
-            var values = GetValues(3);
-            Stack.Push(values);
-
-            interpreter.IntegerStack.Push(1);
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".SHOVE"));
-
-            Assert.AreEqual(values[0], Stack[0]);
-            Assert.AreEqual(values[2], Stack[1]);
-            Assert.AreEqual(values[1], Stack[2]);
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestShoveWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("SHOVE", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestShoveWithNegativeIndex()
-        {
-            TestWithNegativeIndex("SHOVE");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYank()
-        {
-            var values = GetValues(3);
-            Stack.Push(values);
-
-            interpreter.IntegerStack.Push(1);
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".YANK"));
-
-            Assert.AreEqual(values[0], Stack[0]);
-            Assert.AreEqual(values[2], Stack[1]);
-            Assert.AreEqual(values[1], Stack[2]);
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYankWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("YANK", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYankWithNegativeIndex()
-        {
-            TestWithNegativeIndex("YANK");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYankDuplicate()
-        {
-            var values = GetValues(3);
-            Stack.Push(values);
-
-            interpreter.IntegerStack.Push(1);
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".YANKDUP"));
-
-            Assert.AreEqual(values[0], Stack[0]);
-            Assert.AreEqual(values[1], Stack[1]);
-            Assert.AreEqual(values[2], Stack[2]);
-            Assert.AreEqual(values[1], Stack[3]);
-
-            CheckOtherStacksAreEmpty();
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYankDuplicateWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("YANKDUP", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestYankDuplicateWithNegativeIndex()
-        {
-            TestWithNegativeIndex("YANKDUP");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("CommonExpressionTest")]
-        public virtual void TestStackdpeth()
-        {
-            var values = GetValues(3);
-            Stack.Push(values);
-
-            Test(ExpressionTable.GetStatelessExpression(TypeName + ".STACKDEPTH"));
-
-            // if stack is integer stack
-            if (Stack.Count != values.Length)
-            {
-                Assert.AreEqual(4, Stack.Count);
-                CheckOtherStacksAreEmpty();
-            }
-            else
-            {
-                Assert.AreEqual(3, Stack.Count);
-                Assert.AreEqual(values.Length, interpreter.IntegerStack.Top);
-            }
-        }
-
-        protected void TestWithInsufficientArguments(string instructionName, int argCount = 0)
-        {
-            for (var i = 0; i < argCount + 1; i++)
-            {
-                var values = GetValues(i);
-                Stack.Push(values);
-
-                var fullInstructionname = string.Format(FullInstructionNameFormat, TypeName, instructionName);
-                Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
-
-                for (var j = 0; j < i; j++)
-                {
-                    Assert.AreEqual(values[j], Stack[j]);
-                }
-
-                CheckOtherStacksAreEmpty();
-                interpreter.Clear();
-            }
-        }
-
-        protected void TestWithNegativeIndex(string instructionName)
-        {
-            var values = GetValues(1);
-            Stack.Push(values);
-
-            interpreter.IntegerStack.Push(-1);
-
-            var fullInstructionname = string.Format(FullInstructionNameFormat, TypeName, instructionName);
-            Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
-
-            Assert.AreEqual(values[0], Stack[0]);
-        }
-    }
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  public abstract class CommonTests<T> : ExpressionTest {
+    protected const string FullInstructionNameFormat = "{0}.{1}";
+
+    protected abstract string TypeName { get; }
+
+    protected abstract IStack<T> Stack { get; }
+
+    protected abstract T[] GetValues(int count);
+
+    protected virtual T[] Get2Different() {
+      return this.GetValues(2);
+    }
+
+    protected virtual void Test(Expression expression) {
+      this.interpreter.Interpret(expression);
+    }
+
+    protected abstract void CheckOtherStacksAreEmpty();
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestEqualsTrue() {
+      var values = this.GetValues(1);
+      var merged = new[] { values[0], values[0] };
+
+      this.Stack.Push(merged);
+
+      var isBooleanStack = this.interpreter.BooleanStack.Count == 2;
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".="));
+
+      if (isBooleanStack) Assert.AreEqual(1, this.Stack.Count);
+      else Assert.AreEqual(0, this.Stack.Count);
+
+      Assert.IsTrue(this.interpreter.BooleanStack.Top);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestEqualsFalse() {
+      var values = this.Get2Different();
+      this.Stack.Push(values);
+      var isBooleanStack = this.interpreter.BooleanStack.Count == 2;
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".="));
+
+      if (isBooleanStack) Assert.AreEqual(1, this.Stack.Count);
+      else Assert.AreEqual(0, this.Stack.Count);
+
+      Assert.IsFalse(this.interpreter.BooleanStack.Top);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestEqualsWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("=", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestDuplicate() {
+      var values = this.GetValues(1);
+      this.Stack.Push(values);
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".DUP"));
+
+      Assert.AreEqual(this.Stack.Count, 2);
+      Assert.AreEqual(this.Stack[0], values[0]);
+      Assert.AreEqual(this.Stack[1], values[0]);
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestPop() {
+      var values = this.GetValues(2);
+      this.Stack.Push(values);
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".POP"));
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestSwap() {
+      var values = this.GetValues(3);
+      this.Stack.Push(values);
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SWAP"));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+      Assert.AreEqual(values[2], this.Stack[1]);
+      Assert.AreEqual(values[1], this.Stack[2]);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestSwapWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("SWAP", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestRotate() {
+      var values = this.GetValues(4);
+      this.Stack.Push(values);
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".ROT"));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+      Assert.AreEqual(values[3], this.Stack[1]);
+      Assert.AreEqual(values[1], this.Stack[2]);
+      Assert.AreEqual(values[2], this.Stack[3]);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestRotateWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("ROT", 2);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestShove() {
+      var values = this.GetValues(3);
+      this.Stack.Push(values);
+
+      this.interpreter.IntegerStack.Push(1);
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".SHOVE"));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+      Assert.AreEqual(values[2], this.Stack[1]);
+      Assert.AreEqual(values[1], this.Stack[2]);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestShoveWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("SHOVE", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestShoveWithNegativeIndex() {
+      this.TestWithNegativeIndex("SHOVE");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYank() {
+      var values = this.GetValues(3);
+      this.Stack.Push(values);
+
+      this.interpreter.IntegerStack.Push(1);
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANK"));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+      Assert.AreEqual(values[2], this.Stack[1]);
+      Assert.AreEqual(values[1], this.Stack[2]);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYankWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("YANK", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYankWithNegativeIndex() {
+      this.TestWithNegativeIndex("YANK");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYankDuplicate() {
+      var values = this.GetValues(3);
+      this.Stack.Push(values);
+
+      this.interpreter.IntegerStack.Push(1);
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".YANKDUP"));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+      Assert.AreEqual(values[1], this.Stack[1]);
+      Assert.AreEqual(values[2], this.Stack[2]);
+      Assert.AreEqual(values[1], this.Stack[3]);
+
+      this.CheckOtherStacksAreEmpty();
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYankDuplicateWithInsufficientArguments() {
+      this.TestWithInsufficientArguments("YANKDUP", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestYankDuplicateWithNegativeIndex() {
+      this.TestWithNegativeIndex("YANKDUP");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("CommonExpressionTest")]
+    public virtual void TestStackdpeth() {
+      var values = this.GetValues(3);
+      this.Stack.Push(values);
+
+      this.Test(ExpressionTable.GetStatelessExpression(this.TypeName + ".STACKDEPTH"));
+
+      // if stack is integer stack
+      if (this.Stack.Count != values.Length) {
+        Assert.AreEqual(4, this.Stack.Count);
+        this.CheckOtherStacksAreEmpty();
+      } else {
+        Assert.AreEqual(3, this.Stack.Count);
+        Assert.AreEqual(values.Length, this.interpreter.IntegerStack.Top);
+      }
+    }
+
+    protected void TestWithInsufficientArguments(string instructionName, int argCount = 0) {
+      for (var i = 0; i < argCount + 1; i++) {
+        var values = this.GetValues(i);
+        this.Stack.Push(values);
+
+        var fullInstructionname = string.Format(FullInstructionNameFormat, this.TypeName, instructionName);
+        this.Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
+
+        for (var j = 0; j < i; j++) Assert.AreEqual(values[j], this.Stack[j]);
+
+        this.CheckOtherStacksAreEmpty();
+        this.interpreter.Clear();
+      }
+    }
+
+    protected void TestWithNegativeIndex(string instructionName) {
+      var values = this.GetValues(1);
+      this.Stack.Push(values);
+
+      this.interpreter.IntegerStack.Push(-1);
+
+      var fullInstructionname = string.Format(FullInstructionNameFormat, this.TypeName, instructionName);
+      this.Test(ExpressionTable.GetStatelessExpression(fullInstructionname));
+
+      Assert.AreEqual(values[0], this.Stack[0]);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExampleTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExampleTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExampleTests.cs	(revision 14513)
@@ -1,273 +1,257 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-    [TestClass]
-    public class MixedExpressionTests : ExpressionTest
-    {
-        const double Delta = 0.00000001;
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example1()
-        {
-            interpreter.Interpret("( 2 3 INTEGER.* 4.1 5.2 FLOAT.+ TRUE FALSE BOOLEAN.OR )");
-
-            Assert.AreEqual(6, interpreter.IntegerStack.Top);
-            Assert.AreEqual(9.3, interpreter.FloatStack.Top);
-            Assert.AreEqual(interpreter.BooleanStack.Top, true);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example2()
-        {
-            interpreter.Interpret("( 5 1.23 INTEGER.+ ( 4 ) INTEGER.- 5.67 FLOAT.* )");
-
-            Assert.AreEqual(1, interpreter.IntegerStack.Top);
-            Assert.AreEqual(6.9741, interpreter.FloatStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example3()
-        {
-            interpreter.Interpret("( 5 INTEGER.DUP INTEGER.+ )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example4()
-        {
-            interpreter.Interpret("( 5 CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) CODE.DO )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example5()
-        {
-            interpreter.Interpret("( DOUBLE CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) CODE.DEFINE 5 DOUBLE )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example6()
-        {
-            interpreter.Interpret("( CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) DOUBLE CODE.DEFINE 5 DOUBLE )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example7()
-        {
-            interpreter.Interpret("( DOUBLE EXEC.DEFINE ( INTEGER.DUP INTEGER.+ ) 5 DOUBLE )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example8()
-        {
-            interpreter.Configuration.TopLevelPushCode = true;
-
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret(@"( CODE.QUOTE ( INTEGER.POP 1 )
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Parser;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class MixedExpressionTests : ExpressionTest {
+    private const double Delta = 0.00000001;
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example1() {
+      this.interpreter.Interpret("( 2 3 INTEGER.* 4.1 5.2 FLOAT.+ TRUE FALSE BOOLEAN.OR )");
+
+      Assert.AreEqual(6, this.interpreter.IntegerStack.Top);
+      Assert.AreEqual(9.3, this.interpreter.FloatStack.Top);
+      Assert.IsTrue(this.interpreter.BooleanStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example2() {
+      this.interpreter.Interpret("( 5 1.23 INTEGER.+ ( 4 ) INTEGER.- 5.67 FLOAT.* )");
+
+      Assert.AreEqual(1, this.interpreter.IntegerStack.Top);
+      Assert.AreEqual(6.9741, this.interpreter.FloatStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example3() {
+      this.interpreter.Interpret("( 5 INTEGER.DUP INTEGER.+ )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example4() {
+      this.interpreter.Interpret("( 5 CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) CODE.DO )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example5() {
+      this.interpreter.Interpret("( DOUBLE CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) CODE.DEFINE 5 DOUBLE )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example6() {
+      this.interpreter.Interpret("( CODE.QUOTE ( INTEGER.DUP INTEGER.+ ) DOUBLE CODE.DEFINE 5 DOUBLE )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example7() {
+      this.interpreter.Interpret("( DOUBLE EXEC.DEFINE ( INTEGER.DUP INTEGER.+ ) 5 DOUBLE )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example8() {
+      this.interpreter.Configuration.TopLevelPushCode = true;
+
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret(@"( CODE.QUOTE ( INTEGER.POP 1 )
                                            CODE.QUOTE ( CODE.DUP INTEGER.DUP 1 INTEGER.- CODE.DO INTEGER.* )
                                            INTEGER.DUP 2 INTEGER.< CODE.IF )");
 
-            Assert.AreEqual(120, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.Count == 1);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example9()
-        {
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret("( 1 INTEGER.MAX 1 EXEC.DO*RANGE INTEGER.* )");
-
-            Assert.AreEqual(120, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example10()
-        {
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret("( 1 INTEGER.MAX 1 EXEC.DO*RANGE ( 2 INTEGER.* ) )");
-
-            Assert.AreEqual(2, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example11()
-        {
-            var program = PushGPInterpreter.Encode("( INTEGER.= CODE.QUOTE FLOAT.* CODE.QUOTE FLOAT./ CODE.IF )");
-
-            interpreter.IntegerStack.Push(1, 1);
-            interpreter.FloatStack.Push(2.1, 0.7);
-
-            interpreter.Interpret(program);
-
-            Assert.IsTrue(interpreter.IntegerStack.IsEmpty);
-            Assert.AreEqual(1.47, interpreter.FloatStack.Top, Delta);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-
-            interpreter.Clear();
-            interpreter.IntegerStack.Push(1, 2);
-            interpreter.FloatStack.Push(2.1, 0.7);
-            interpreter.Interpret(program);
-
-            Assert.IsTrue(interpreter.IntegerStack.IsEmpty);
-            Assert.AreEqual(3d, interpreter.FloatStack.Top, Delta);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example12()
-        {
-            var program = PushGPInterpreter.Encode("( INTEGER.= EXEC.IF FLOAT.* FLOAT./ )");
-
-            interpreter.IntegerStack.Push(1, 1);
-            interpreter.FloatStack.Push(2.1, 0.7);
-
-            interpreter.Interpret(program);
-
-            Assert.IsTrue(interpreter.IntegerStack.IsEmpty);
-            Assert.AreEqual(1.47, interpreter.FloatStack.Top, Delta);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-
-            interpreter.Clear();
-            interpreter.IntegerStack.Push(1, 2);
-            interpreter.FloatStack.Push(2.1, 0.7);
-            interpreter.Interpret(program);
-
-            Assert.IsTrue(interpreter.IntegerStack.IsEmpty);
-            Assert.AreEqual(3d, interpreter.FloatStack.Top, Delta);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example13()
-        {
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret("( EXEC.Y ( ( FALSE 2 INTEGER.* ) EXEC.IF ( ) EXEC.POP ) )");
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example14()
-        {
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret("( EXEC.Y ( ( 2 INTEGER.* INTEGER.DUP 1000 INTEGER.< ) EXEC.IF ( ) EXEC.POP ) )");
-
-            Assert.AreEqual(1280, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-            Assert.IsTrue(interpreter.FloatStack.IsEmpty);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExampleTest")]
-        public void Example15()
-        {
-            interpreter.IntegerStack.Push(10);
-            interpreter.FloatStack.Push(2);
-            interpreter.Interpret(@"( ARG FLOAT.DEFINE
+      Assert.AreEqual(120, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.Count == 1);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example9() {
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret("( 1 INTEGER.MAX 1 EXEC.DO*RANGE INTEGER.* )");
+
+      Assert.AreEqual(120, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example10() {
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret("( 1 INTEGER.MAX 1 EXEC.DO*RANGE ( 2 INTEGER.* ) )");
+
+      Assert.AreEqual(2, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example11() {
+      var program = PushGPParser.Parse("( INTEGER.= CODE.QUOTE FLOAT.* CODE.QUOTE FLOAT./ CODE.IF )");
+
+      this.interpreter.IntegerStack.Push(1, 1);
+      this.interpreter.FloatStack.Push(2.1, 0.7);
+
+      this.interpreter.Interpret(program);
+
+      Assert.IsTrue(this.interpreter.IntegerStack.IsEmpty);
+      Assert.AreEqual(1.47, this.interpreter.FloatStack.Top, Delta);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+
+      this.interpreter.Clear();
+      this.interpreter.IntegerStack.Push(1, 2);
+      this.interpreter.FloatStack.Push(2.1, 0.7);
+      this.interpreter.Interpret(program);
+
+      Assert.IsTrue(this.interpreter.IntegerStack.IsEmpty);
+      Assert.AreEqual(3d, this.interpreter.FloatStack.Top, Delta);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example12() {
+      var program = PushGPParser.Parse("( INTEGER.= EXEC.IF FLOAT.* FLOAT./ )");
+
+      this.interpreter.IntegerStack.Push(1, 1);
+      this.interpreter.FloatStack.Push(2.1, 0.7);
+
+      this.interpreter.Interpret(program);
+
+      Assert.IsTrue(this.interpreter.IntegerStack.IsEmpty);
+      Assert.AreEqual(1.47, this.interpreter.FloatStack.Top, Delta);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+
+      this.interpreter.Clear();
+      this.interpreter.IntegerStack.Push(1, 2);
+      this.interpreter.FloatStack.Push(2.1, 0.7);
+      this.interpreter.Interpret(program);
+
+      Assert.IsTrue(this.interpreter.IntegerStack.IsEmpty);
+      Assert.AreEqual(3d, this.interpreter.FloatStack.Top, Delta);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example13() {
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret("( EXEC.Y ( ( FALSE 2 INTEGER.* ) EXEC.IF ( ) EXEC.POP ) )");
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example14() {
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret("( EXEC.Y ( ( 2 INTEGER.* INTEGER.DUP 1000 INTEGER.< ) EXEC.IF ( ) EXEC.POP ) )");
+
+      Assert.AreEqual(1280, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.FloatStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example15() {
+      this.interpreter.IntegerStack.Push(10);
+      this.interpreter.FloatStack.Push(2);
+      this.interpreter.Interpret(@"( ARG FLOAT.DEFINE
                                            EXEC.Y (
                                            ARG FLOAT.*
@@ -278,11 +262,25 @@
                                          )");
 
-            Assert.AreEqual(1024, interpreter.FloatStack.Top, Delta);
-            Assert.AreEqual(1, interpreter.IntegerStack.Top);
-            Assert.IsTrue(interpreter.CodeStack.IsEmpty);
-            Assert.IsTrue(interpreter.ExecStack.IsEmpty);
-            Assert.IsTrue(interpreter.NameStack.IsEmpty);
-            Assert.IsTrue(interpreter.BooleanStack.IsEmpty);
-        }
-    }
+      Assert.AreEqual(1024, this.interpreter.FloatStack.Top, Delta);
+      Assert.AreEqual(1, this.interpreter.IntegerStack.Top);
+      Assert.IsTrue(this.interpreter.CodeStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.ExecStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.NameStack.IsEmpty);
+      Assert.IsTrue(this.interpreter.BooleanStack.IsEmpty);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExampleTest")]
+    public void Example16() {
+      var list = PushGPParser.Parse("( A B C )");
+
+      this.interpreter.CodeStack.Push(list);
+      this.interpreter.Interpret("( CODE.DUP 0 CODE.INSERT )");
+
+      var id = this.interpreter.CodeStack.Top.GetHashCode();
+
+      if (id == default(int)) Assert.Fail();
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/ExecExpressionTests.cs	(revision 14513)
@@ -1,163 +1,157 @@
-﻿using HeuristicLab.Algorithms.PushGP;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions {
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Parser;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-    [TestClass]
-    public class ExecExpressionTests : CommonTests<Expression>
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class ExecExpressionTests : CommonTests<Expression> {
+    protected override string TypeName
     {
-        protected override string TypeName { get { return "EXEC"; } }
+      get
+      {
+        return "EXEC";
+      }
+    }
 
-        protected override IStack<Expression> Stack { get { return interpreter.ExecStack; } }
+    protected override IStack<Expression> Stack
+    {
+      get
+      {
+        return this.interpreter.ExecStack;
+      }
+    }
 
-        protected override void Test(Expression expression)
-        {
-            interpreter.InterpretAsync(expression, true).Wait();
-        }
+    protected override void Test(Expression expression) {
+      this.interpreter.InterpretAsync(expression, true).Wait();
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestIfTrue()
-        {
-            interpreter.BooleanStack.Push(true);
-            interpreter.Interpret("( EXEC.IF WAHR FALSCH )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestIfTrue() {
+      this.interpreter.BooleanStack.Push(true);
+      this.interpreter.Interpret("( EXEC.IF WAHR FALSCH )");
 
-            Assert.AreEqual("WAHR", interpreter.NameStack.Top);
-            TestStackCounts(nameStack: 1);
-        }
+      Assert.AreEqual("WAHR", this.interpreter.NameStack.Top);
+      this.TestStackCounts(nameStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestIfFalse()
-        {
-            interpreter.BooleanStack.Push(false);
-            interpreter.Interpret("( EXEC.IF WAHR FALSCH )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestIfFalse() {
+      this.interpreter.BooleanStack.Push(false);
+      this.interpreter.Interpret("( EXEC.IF WAHR FALSCH )");
 
-            Assert.AreEqual("FALSCH", interpreter.NameStack.Top);
-            TestStackCounts(nameStack: 1);
-        }
+      Assert.AreEqual("FALSCH", this.interpreter.NameStack.Top);
+      this.TestStackCounts(nameStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestK()
-        {
-            var first = Parser.Parse("A");
-            var second = Parser.Parse("B");
-            var third = Parser.Parse("C");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestK() {
+      var first = PushGPParser.Parse("A");
+      var second = PushGPParser.Parse("B");
+      var third = PushGPParser.Parse("C");
 
-            interpreter.ExecStack.Push(third, second, first);
-            Test(new ExecKExpression());
+      this.interpreter.ExecStack.Push(third, second, first);
+      this.Test(new ExecKExpression());
 
-            Assert.AreEqual(first, interpreter.ExecStack.Top);
-            Assert.AreEqual(third, interpreter.ExecStack.Bottom);
-            TestStackCounts(execStack: 2);
-        }
+      Assert.AreEqual(first, this.interpreter.ExecStack.Top);
+      Assert.AreEqual(third, this.interpreter.ExecStack.Bottom);
+      this.TestStackCounts(2);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestS()
-        {
-            var first = Parser.Parse("A");
-            var second = Parser.Parse("B");
-            var third = Parser.Parse("C");
-            var result = Parser.Parse("( B C )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestS() {
+      var first = PushGPParser.Parse("A");
+      var second = PushGPParser.Parse("B");
+      var third = PushGPParser.Parse("C");
+      var result = PushGPParser.Parse("( B C )");
 
-            interpreter.ExecStack.Push(third, second, first);
-            Test(new ExecSExpression());
+      this.interpreter.ExecStack.Push(third, second, first);
+      this.Test(new ExecSExpression());
 
-            Assert.AreEqual(result, interpreter.ExecStack.ReverseElementAt(2));
-            Assert.AreEqual(third, interpreter.ExecStack.ReverseElementAt(1));
-            Assert.AreEqual(first, interpreter.ExecStack.Top);
-            TestStackCounts(execStack: 3);
-        }
+      Assert.AreEqual(result, this.interpreter.ExecStack.ReverseElementAt(2));
+      Assert.AreEqual(third, this.interpreter.ExecStack.ReverseElementAt(1));
+      Assert.AreEqual(first, this.interpreter.ExecStack.Top);
+      this.TestStackCounts(3);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestY()
-        {
-            var first = Parser.Parse("A");
-            var result = Parser.Parse("( EXEC.Y A )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestY() {
+      var first = PushGPParser.Parse("A");
+      var result = PushGPParser.Parse("( EXEC.Y A )");
 
-            interpreter.ExecStack.Push(first);
-            Test(new ExecYExpression());
+      this.interpreter.ExecStack.Push(first);
+      this.Test(new ExecYExpression());
 
-            Assert.AreEqual(first, interpreter.ExecStack.Top);
-            Assert.AreEqual(result, interpreter.ExecStack.ReverseElementAt(1));
-            TestStackCounts(execStack: 2);
-        }
+      Assert.AreEqual(first, this.interpreter.ExecStack.Top);
+      Assert.AreEqual(result, this.interpreter.ExecStack.ReverseElementAt(1));
+      this.TestStackCounts(2);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestNestedDoRange()
-        {
-            interpreter.Interpret("( 0 2 EXEC.DO*RANGE ( 1 INTEGER.+ 0 3 EXEC.DO*RANGE ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestNestedDoRange() {
+      this.interpreter.Interpret(
+        "( 0 2 EXEC.DO*RANGE ( 1 INTEGER.+ 0 3 EXEC.DO*RANGE ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )");
 
-            Assert.AreEqual(144, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
+      Assert.AreEqual(144, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestNestedDoCount()
-        {
-            interpreter.Interpret("( 2 EXEC.DO*COUNT ( 1 INTEGER.+ 3 EXEC.DO*COUNT ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestNestedDoCount() {
+      this.interpreter.Interpret(
+        "( 2 EXEC.DO*COUNT ( 1 INTEGER.+ 3 EXEC.DO*COUNT ( 1 INTEGER.+ INTEGER.* ) INTEGER.+ )");
 
-            Assert.AreEqual(144, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
+      Assert.AreEqual(144, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("ExecExpressionTest")]
-        public void TestNestedDoTimes()
-        {
-            interpreter.Interpret("( 3 EXEC.DO*TIMES ( 2 3 EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )");
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("ExecExpressionTest")]
+    public void TestNestedDoTimes() {
+      this.interpreter.Interpret("( 3 EXEC.DO*TIMES ( 2 3 EXEC.DO*TIMES ( 2 INTEGER.* ) INTEGER.+ )");
 
-            Assert.AreEqual(128, interpreter.IntegerStack.Top);
-            TestStackCounts(integerStack: 1);
-        }
+      Assert.AreEqual(128, this.interpreter.IntegerStack.Top);
+      this.TestStackCounts(integerStack: 1);
+    }
 
-        protected override Expression[] GetValues(int count)
-        {
-            var values = new Expression[count];
+    protected override Expression[] GetValues(int count) {
+      var values = new Expression[count];
 
-            for (var i = 0; i < count; i++)
-            {
-                values[i] = new CodeNoopExpression();
-            }
+      for (var i = 0; i < count; i++) values[i] = new CodeNoopExpression();
 
-            return values;
-        }
+      return values;
+    }
 
-        protected override Expression[] Get2Different()
-        {
-            return new Expression[]
-            {
-                new CodeNoopExpression(),
-                new CodeNullExpression()
-            };
-        }
+    protected override Expression[] Get2Different() {
+      return new Expression[] { new CodeNoopExpression(), new CodeNullExpression() };
+    }
 
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(execStack: null);
-        }
+    protected override void CheckOtherStacksAreEmpty() {
+      this.TestStackCounts(null);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/FloatExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/FloatExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/FloatExpressionTests.cs	(revision 14513)
@@ -1,345 +1,358 @@
-﻿using System;
-using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter.Expressions
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions
 {
-    [TestClass]
-    public class FloatExpressionTests : CommonTests<double>
-    {
-        private const double delta = 0.00001;
-        protected override string TypeName { get { return "FLOAT"; } }
-        protected override IStack<double> Stack { get { return interpreter.FloatStack; } }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestAdd()
-        {
-            interpreter.FloatStack.Push(5.3, 5.3);
-            interpreter.Interpret(new FloatAddExpression());
-
-            Assert.AreEqual(10.6, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestAddWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("+", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSubtract()
-        {
-            interpreter.FloatStack.Push(10.2, 5.3);
-            interpreter.Interpret(new FloatSubtractExpression());
-
-            Assert.AreEqual(4.9, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSubractWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("-", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMultiply()
-        {
-            interpreter.FloatStack.Push(9.9, 3.3);
-            interpreter.Interpret(new FloatMultiplyExpression());
-
-            Assert.AreEqual(32.67, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMultiplyWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("*", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestDivide()
-        {
-            interpreter.FloatStack.Push(9.9, 3.3);
-            interpreter.Interpret(new FloatDivideExpression());
-
-            Assert.AreEqual(3.0, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestDivideWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("/", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestModulo()
-        {
-            interpreter.FloatStack.Push(11.6, 5.3);
-            interpreter.Interpret(new FloatModuloExpression());
-
-            Assert.AreEqual(1, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestModuloWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("%", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMin()
-        {
-            interpreter.FloatStack.Push(10.2, 5.3);
-            interpreter.Interpret(new FloatMinExpression());
-
-            Assert.AreEqual(5.3, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMinWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("MIN", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMax()
-        {
-            interpreter.FloatStack.Push(10.3, 5.3);
-            interpreter.Interpret(new FloatMaxExpression());
-
-            Assert.AreEqual(10.3, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestMaxWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("MAX", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSmallerThan()
-        {
-            interpreter.FloatStack.Push(10.2, 5.3);
-            interpreter.Interpret(new FloatSmallerThanExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSmallerThanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("<", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestGreaterThan()
-        {
-            interpreter.FloatStack.Push(10.2, 5.3);
-            interpreter.Interpret(new FloatGreaterThanExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestGreaterThanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments(">", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestFromBooleanTrue()
-        {
-            interpreter.BooleanStack.Push(true);
-            interpreter.Interpret(new FloatFromBooleanExpression());
-
-            Assert.AreEqual(1d, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestFromBooleanFalse()
-        {
-            interpreter.BooleanStack.Push(false);
-            interpreter.Interpret(new FloatFromBooleanExpression());
-
-            Assert.AreEqual(0d, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestFromBooleanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMBOOLEAN");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestFromInteger()
-        {
-            interpreter.IntegerStack.Push(5);
-            interpreter.Interpret(new FloatFromIntegerExpression());
-
-            Assert.AreEqual(5d, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestFromIntegerWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMINTEGER");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSine()
-        {
-            interpreter.FloatStack.Push(Math.PI / 2);
-            interpreter.Interpret(new FloatSineExpression());
-
-            Assert.AreEqual(1, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestSineWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("SIN");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestCosine()
-        {
-            interpreter.FloatStack.Push(Math.PI);
-            interpreter.Interpret(new FloatCosineExpression());
-
-            Assert.AreEqual(-1, interpreter.FloatStack.Top, delta);
-
-            TestStackCounts(floatStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("FloatExpressionTest")]
-        public void TestCosineWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("COS");
-        }
-
-        protected override double[] GetValues(int count)
-        {
-            var values = new double[count];
-
-            for (var i = 0; i < count; i++)
-            {
-                values[i] = i * 0.9;
-            }
-
-            return values;
-        }
-
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(floatStack: null);
-        }
-    }
+  using System;
+
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class FloatExpressionTests : CommonTests<double>
+  {
+    private const double delta = 0.00001;
+
+    protected override string TypeName
+    {
+      get
+      {
+        return "FLOAT";
+      }
+    }
+
+    protected override IStack<double> Stack
+    {
+      get
+      {
+        return this.interpreter.FloatStack;
+      }
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestAdd()
+    {
+      this.interpreter.FloatStack.Push(5.3, 5.3);
+      this.interpreter.Interpret(new FloatAddExpression());
+
+      Assert.AreEqual(10.6, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestAddWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("+", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSubtract()
+    {
+      this.interpreter.FloatStack.Push(10.2, 5.3);
+      this.interpreter.Interpret(new FloatSubtractExpression());
+
+      Assert.AreEqual(4.9, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSubractWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("-", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMultiply()
+    {
+      this.interpreter.FloatStack.Push(9.9, 3.3);
+      this.interpreter.Interpret(new FloatMultiplyExpression());
+
+      Assert.AreEqual(32.67, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMultiplyWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("*", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestDivide()
+    {
+      this.interpreter.FloatStack.Push(9.9, 3.3);
+      this.interpreter.Interpret(new FloatDivideExpression());
+
+      Assert.AreEqual(3.0, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestDivideWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("/", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestModulo()
+    {
+      this.interpreter.FloatStack.Push(11.6, 5.3);
+      this.interpreter.Interpret(new FloatModuloExpression());
+
+      Assert.AreEqual(1, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestModuloWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("%", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMin()
+    {
+      this.interpreter.FloatStack.Push(10.2, 5.3);
+      this.interpreter.Interpret(new FloatMinExpression());
+
+      Assert.AreEqual(5.3, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMinWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("MIN", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMax()
+    {
+      this.interpreter.FloatStack.Push(10.3, 5.3);
+      this.interpreter.Interpret(new FloatMaxExpression());
+
+      Assert.AreEqual(10.3, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestMaxWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("MAX", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSmallerThan()
+    {
+      this.interpreter.FloatStack.Push(10.2, 5.3);
+      this.interpreter.Interpret(new FloatSmallerThanExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSmallerThanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("<", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestGreaterThan()
+    {
+      this.interpreter.FloatStack.Push(10.2, 5.3);
+      this.interpreter.Interpret(new FloatGreaterThanExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestGreaterThanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments(">", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestFromBooleanTrue()
+    {
+      this.interpreter.BooleanStack.Push(true);
+      this.interpreter.Interpret(new FloatFromBooleanExpression());
+
+      Assert.AreEqual(1d, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestFromBooleanFalse()
+    {
+      this.interpreter.BooleanStack.Push(false);
+      this.interpreter.Interpret(new FloatFromBooleanExpression());
+
+      Assert.AreEqual(0d, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestFromBooleanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMBOOLEAN");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestFromInteger()
+    {
+      this.interpreter.IntegerStack.Push(5);
+      this.interpreter.Interpret(new FloatFromIntegerExpression());
+
+      Assert.AreEqual(5d, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestFromIntegerWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMINTEGER");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSine()
+    {
+      this.interpreter.FloatStack.Push(Math.PI / 2);
+      this.interpreter.Interpret(new FloatSineExpression());
+
+      Assert.AreEqual(1, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestSineWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("SIN");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestCosine()
+    {
+      this.interpreter.FloatStack.Push(Math.PI);
+      this.interpreter.Interpret(new FloatCosineExpression());
+
+      Assert.AreEqual(-1, this.interpreter.FloatStack.Top, delta);
+
+      this.TestStackCounts(floatStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("FloatExpressionTest")]
+    public void TestCosineWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("COS");
+    }
+
+    protected override double[] GetValues(int count)
+    {
+      var values = new double[count];
+
+      for (var i = 0; i < count; i++) values[i] = i * 0.9;
+
+      return values;
+    }
+
+    protected override void CheckOtherStacksAreEmpty()
+    {
+      this.TestStackCounts(floatStack: null);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/IntegerExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/IntegerExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/IntegerExpressionTests.cs	(revision 14513)
@@ -1,297 +1,308 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter.Expressions
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions
 {
-    [TestClass]
-    public class IntegerExpressionTests : CommonTests<long>
-    {
-        protected override string TypeName { get { return "INTEGER"; } }
-        protected override IStack<long> Stack { get { return interpreter.IntegerStack; } }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestAdd()
-        {
-            interpreter.IntegerStack.Push(5, 5);
-            interpreter.Interpret(new IntegerAddExpression());
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestAddWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("+", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestSubtract()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerSubtractExpression());
-
-            Assert.AreEqual(5, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestSubtractWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("-", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMultiply()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerMultiplyExpression());
-
-            Assert.AreEqual(50, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMultiplyWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("*", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestDivide()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerDivideExpression());
-
-            Assert.AreEqual(2, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestDivideWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("/", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestModulo()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerModuloExpression());
-
-            Assert.AreEqual(0, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestModuloWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("%", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMin()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerMinExpression());
-
-            Assert.AreEqual(5, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMinWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("MIN", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMax()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerMaxExpression());
-
-            Assert.AreEqual(10, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestMaxWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("MAX", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestSmallerThan()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerSmallerThanExpression());
-
-            Assert.AreEqual(false, interpreter.BooleanStack.Top);
-
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestSmallerThanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("<", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestGreaterThan()
-        {
-            interpreter.IntegerStack.Push(10, 5);
-            interpreter.Interpret(new IntegerGreaterThanExpression());
-
-            Assert.AreEqual(true, interpreter.BooleanStack.Top);
-
-            TestStackCounts(booleanStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestGreaterThanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments(">", 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestFromBooleanTrue()
-        {
-            interpreter.BooleanStack.Push(true);
-            interpreter.Interpret(new IntegerFromBooleanExpression());
-
-            Assert.AreEqual(1, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestFromBooleanWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMBOOLEAN");
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestFromBooleanFalse()
-        {
-            interpreter.BooleanStack.Push(false);
-            interpreter.Interpret(new IntegerFromBooleanExpression());
-
-            Assert.AreEqual(0, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestFromFloat()
-        {
-            interpreter.FloatStack.Push(1.5);
-            interpreter.Interpret(new IntegerFromFloatExpression());
-
-            Assert.AreEqual(1, interpreter.IntegerStack.Top);
-
-            TestStackCounts(integerStack: 1);
-        }
-
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("IntegerExpressionTest")]
-        public void TestFromFloatWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("FROMFLOAT");
-        }
-
-        protected override long[] GetValues(int count)
-        {
-            var values = new long[count];
-
-            for (long i = 0; i < count; i++)
-            {
-                values[i] = i;
-            }
-
-            return values;
-        }
-
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(integerStack: null);
-        }
-    }
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Stack;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class IntegerExpressionTests : CommonTests<long>
+  {
+    protected override string TypeName
+    {
+      get
+      {
+        return "INTEGER";
+      }
+    }
+
+    protected override IStack<long> Stack
+    {
+      get
+      {
+        return this.interpreter.IntegerStack;
+      }
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestAdd()
+    {
+      this.interpreter.IntegerStack.Push(5, 5);
+      this.interpreter.Interpret(new IntegerAddExpression());
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestAddWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("+", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestSubtract()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerSubtractExpression());
+
+      Assert.AreEqual(5, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestSubtractWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("-", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMultiply()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerMultiplyExpression());
+
+      Assert.AreEqual(50, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMultiplyWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("*", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestDivide()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerDivideExpression());
+
+      Assert.AreEqual(2, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestDivideWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("/", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestModulo()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerModuloExpression());
+
+      Assert.AreEqual(0, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestModuloWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("%", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMin()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerMinExpression());
+
+      Assert.AreEqual(5, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMinWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("MIN", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMax()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerMaxExpression());
+
+      Assert.AreEqual(10, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestMaxWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("MAX", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestSmallerThan()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerSmallerThanExpression());
+
+      Assert.AreEqual(false, this.interpreter.BooleanStack.Top);
+
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestSmallerThanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("<", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestGreaterThan()
+    {
+      this.interpreter.IntegerStack.Push(10, 5);
+      this.interpreter.Interpret(new IntegerGreaterThanExpression());
+
+      Assert.AreEqual(true, this.interpreter.BooleanStack.Top);
+
+      this.TestStackCounts(booleanStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestGreaterThanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments(">", 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestFromBooleanTrue()
+    {
+      this.interpreter.BooleanStack.Push(true);
+      this.interpreter.Interpret(new IntegerFromBooleanExpression());
+
+      Assert.AreEqual(1, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestFromBooleanWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMBOOLEAN");
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestFromBooleanFalse()
+    {
+      this.interpreter.BooleanStack.Push(false);
+      this.interpreter.Interpret(new IntegerFromBooleanExpression());
+
+      Assert.AreEqual(0, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestFromFloat()
+    {
+      this.interpreter.FloatStack.Push(1.5);
+      this.interpreter.Interpret(new IntegerFromFloatExpression());
+
+      Assert.AreEqual(1, this.interpreter.IntegerStack.Top);
+
+      this.TestStackCounts(integerStack: 1);
+    }
+
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("IntegerExpressionTest")]
+    public void TestFromFloatWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("FROMFLOAT");
+    }
+
+    protected override long[] GetValues(int count)
+    {
+      var values = new long[count];
+
+      for (long i = 0; i < count; i++) values[i] = i;
+
+      return values;
+    }
+
+    protected override void CheckOtherStacksAreEmpty()
+    {
+      this.TestStackCounts(integerStack: null);
+    }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/NameExpressionTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/NameExpressionTests.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/NameExpressionTests.cs	(revision 14513)
@@ -1,85 +1,95 @@
-﻿using HeuristicLab.Algorithms.PushGP.Expressions;
-using HeuristicLab.Algorithms.PushGP.Generators;
-using HeuristicLab.Algorithms.PushGP.Stack;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions
+{
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Generators;
+  using HeuristicLab.Algorithms.PushGP.Stack;
 
-namespace HeuristicLab.Tests.Interpreter.Expressions
-{
-    [TestClass]
-    public class NameExpressionTests : CommonTests<string>
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class NameExpressionTests : CommonTests<string>
+  {
+    protected override string TypeName
     {
+      get
+      {
+        return "NAME";
+      }
+    }
 
-        protected override string TypeName { get { return "NAME"; } }
-        protected override IStack<string> Stack { get { return interpreter.NameStack; } }
+    protected override IStack<string> Stack
+    {
+      get
+      {
+        return this.interpreter.NameStack;
+      }
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("NameExpressionTest")]
-        public void TestRand()
-        {
-            interpreter.Interpret(new NameRandExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("NameExpressionTest")]
+    public void TestRand()
+    {
+      this.interpreter.Interpret(new NameRandExpression());
 
-            Assert.IsTrue(interpreter.NameStack.Count == 1);
+      Assert.IsTrue(this.interpreter.NameStack.Count == 1);
 
-            CheckOtherStacksAreEmpty();
-        }
+      this.CheckOtherStacksAreEmpty();
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("NameExpressionTest")]
-        public void TestRandomBound()
-        {
-            interpreter.CustomExpressions.Add("c1", new CodeNoopExpression());
-            interpreter.CustomExpressions.Add("c2", new CodeNoopExpression());
-            interpreter.CustomExpressions.Add("c3", new CodeNoopExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("NameExpressionTest")]
+    public void TestRandomBound()
+    {
+      this.interpreter.CustomExpressions.Add("c1", new CodeNoopExpression());
+      this.interpreter.CustomExpressions.Add("c2", new CodeNoopExpression());
+      this.interpreter.CustomExpressions.Add("c3", new CodeNoopExpression());
 
-            interpreter.Interpret(new NameRandBoundNameExpression());
+      this.interpreter.Interpret(new NameRandBoundNameExpression());
 
-            Assert.IsTrue(interpreter.CustomExpressions.Keys.Contains(interpreter.NameStack.Top));
+      Assert.IsTrue(this.interpreter.CustomExpressions.Keys.Contains(this.interpreter.NameStack.Top));
 
-            CheckOtherStacksAreEmpty();
-        }
+      this.CheckOtherStacksAreEmpty();
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("NameExpressionTest")]
-        public void TestRandomBoundWithInsufficientArguments()
-        {
-            TestWithInsufficientArguments("RANDBOUNDNAME");
-        }
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("NameExpressionTest")]
+    public void TestRandomBoundWithInsufficientArguments()
+    {
+      this.TestWithInsufficientArguments("RANDBOUNDNAME");
+    }
 
-        [TestMethod]
-        [TestProperty("Time", "Short")]
-        [TestCategory("ExpressionTest")]
-        [TestCategory("NameExpressionTest")]
-        public void TestQuote()
-        {
-            interpreter.Interpret(new NameQuoteExpression());
+    [TestMethod]
+    [TestProperty("Time", "Short")]
+    [TestCategory("ExpressionTest")]
+    [TestCategory("NameExpressionTest")]
+    public void TestQuote()
+    {
+      this.interpreter.Interpret(new NameQuoteExpression());
 
-            Assert.IsTrue(interpreter.IsNameQuoteFlagSet);
+      Assert.IsTrue(this.interpreter.IsNameQuoteFlagSet);
 
-            TestStackCounts();
-        }
+      this.TestStackCounts();
+    }
 
-        protected override string[] GetValues(int count)
-        {
-            var ng = new NameGenerator();
-            var values = new string[count];
+    protected override string[] GetValues(int count)
+    {
+      var ng = new NameGenerator();
+      var values = new string[count];
 
-            for (var i = 0; i < count; i++)
-            {
-                values[i] = ng.GetNextString();
-            }
+      for (var i = 0; i < count; i++) values[i] = ng.GetNextString();
 
-            return values;
-        }
+      return values;
+    }
 
-        protected override void CheckOtherStacksAreEmpty()
-        {
-            TestStackCounts(nameStack: null);
-        }
+    protected override void CheckOtherStacksAreEmpty()
+    {
+      this.TestStackCounts(nameStack: null);
     }
+  }
 }
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/StandardTests.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/StandardTests.cs	(revision 14513)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/Expressions/StandardTests.cs	(revision 14513)
@@ -0,0 +1,100 @@
+﻿namespace HeuristicLab.Tests.Interpreter.Expressions {
+  using System;
+  using System.Collections.Generic;
+  using System.Diagnostics;
+  using System.Linq;
+  using HeuristicLab.Algorithms.PushGP.Expressions;
+  using HeuristicLab.Algorithms.PushGP.Parser;
+
+  using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+  [TestClass]
+  public class StandardTests {
+    [TestMethod]
+    public void TestGetHashCode() {
+      var expressionTypes = from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
+                            from assemblyType in domainAssembly.GetTypes()
+                            where
+                            !assemblyType.IsAbstract && assemblyType.IsSubclassOf(typeof(Expression))
+                            && (assemblyType.GetConstructor(Type.EmptyTypes) != null)
+                            select assemblyType;
+
+      var expressions = expressionTypes.Select(et => Activator.CreateInstance(et) as Expression);
+      var ids = expressions.Select(e => new { Epxression = e, Id = e.GetHashCode() });
+
+      var duplicates = ids.GroupBy(s => s).SelectMany(grp => grp.Skip(1));
+
+      if (duplicates.Any()) {
+        Debug.WriteLine("Duplicates: ");
+        foreach (var duplicate in duplicates) Debug.WriteLine("Id: {0}, Expression: {1}", duplicate.Id, duplicate.Epxression);
+
+        Assert.Fail();
+      }
+    }
+
+    [TestMethod]
+    public void TestExpandGetHashCode() {
+      var expand = PushGPParser.Parse("( A B C D E F )");
+
+      expand.GetHashCode();
+    }
+
+    [TestMethod]
+    public void TestExecExpandCopy() {
+      var expressions = new Expression[]
+                          {
+                            new IntegerPushExpression(2), new FloatPushExpression(2.0),
+                            new BooleanPushExpression(true), new NameDefineXExecExpression("A")
+                          };
+
+      var list = new ExecExpandExpression(expressions);
+      var clone = list.Copy();
+
+      Assert.AreNotSame(list, clone);
+      Assert.AreEqual(list, clone);
+    }
+
+    [TestMethod]
+    public void TestExecExpandRecursiveCopy() {
+      var expressions = new List<Expression>
+                          {
+                            new IntegerPushExpression(2),
+                            new FloatPushExpression(2.1),
+                            new BooleanPushExpression(true),
+                            new NameDefineXExecExpression("A")
+                          };
+
+      var list = new ExecExpandExpression(expressions.ToArray());
+
+      expressions.Add(list);
+
+      var list2 = new ExecExpandExpression(expressions.ToArray());
+      var clone = list2.Copy();
+
+      Assert.AreSame(list, clone.Expressions.Last());
+      Assert.AreEqual(list, clone.Expressions.Last());
+
+      Assert.AreNotSame(list2, clone);
+      Assert.AreEqual(list2, clone);
+    }
+
+    [TestMethod]
+    public void TestExecExpandRecursiveGetHashCode() {
+      var expressions = new List<Expression>
+                          {
+                            new IntegerPushExpression(2),
+                            new FloatPushExpression(2.0),
+                            new BooleanPushExpression(true),
+                            new NameDefineXExecExpression("A")
+                          };
+
+      var list = new ExecExpandExpression(expressions.ToArray());
+
+      expressions.Add(list);
+      var list2 = new ExecExpandExpression(expressions.ToArray());
+      var list3 = new ExecExpandExpression(expressions.ToArray());
+
+      Assert.AreEqual(list2.GetHashCode(), list3.GetHashCode());
+    }
+  }
+}
Index: anches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/InterpreterTest.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Interpreter/InterpreterTest.cs	(revision 14512)
+++ 	(revision )
@@ -1,52 +1,0 @@
-﻿using HeuristicLab.Algorithms.PushGP.Interpreter;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests.Interpreter
-{
-    public class ExpressionTest
-    {
-        protected PushGPInterpreter interpreter;
-
-        [TestInitialize]
-        public void BeforeTest()
-        {
-            interpreter = new PushGPInterpreter(new Configuration
-            {
-                TopLevelPushCode = false
-            });
-        }
-
-        protected void TestStackCounts(int? execStack = 0, int? codeStack = 0, int? nameStack = 0, int? booleanStack = 0, int? floatStack = 0, int? integerStack = 0)
-        {
-            if (execStack.HasValue)
-            {
-                Assert.AreEqual(execStack, interpreter.ExecStack.Count);
-            }
-
-            if (codeStack.HasValue)
-            {
-                Assert.AreEqual(codeStack, interpreter.CodeStack.Count);
-            }
-
-            if (nameStack.HasValue)
-            {
-                Assert.AreEqual(nameStack, interpreter.NameStack.Count);
-            }
-
-            if (booleanStack.HasValue)
-            {
-                Assert.AreEqual(booleanStack, interpreter.BooleanStack.Count);
-            }
-
-            if (floatStack.HasValue)
-            {
-                Assert.AreEqual(floatStack, interpreter.FloatStack.Count);
-            }
-
-            if (integerStack.HasValue)
-            {
-                Assert.AreEqual(integerStack, interpreter.IntegerStack.Count);
-            }
-        }
-    }
-}
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Properties/AssemblyInfo.cs
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Properties/AssemblyInfo.cs	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Properties/AssemblyInfo.cs	(revision 14513)
@@ -1,4 +1,3 @@
 ﻿using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
@@ -6,4 +5,5 @@
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
+
 [assembly: AssemblyTitle("HeuristicLab.Tests")]
 [assembly: AssemblyDescription("")]
@@ -18,7 +18,9 @@
 // to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
+
 [assembly: ComVisible(false)]
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
+
 [assembly: Guid("117b7d68-ed7d-4350-996b-9ca15259e107")]
 
@@ -33,4 +35,5 @@
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/PushGP/HeuristicLab.Algorithms.PushGP/PushGp.sln
===================================================================
--- /branches/PushGP/HeuristicLab.Algorithms.PushGP/PushGp.sln	(revision 14512)
+++ /branches/PushGP/HeuristicLab.Algorithms.PushGP/PushGp.sln	(revision 14513)
@@ -11,4 +11,6 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.BenchmarkSuite", "HeuristicLab.BenchmarkSuite\HeuristicLab.BenchmarkSuite.csproj", "{22B5C087-CFC7-4D40-86C6-32FCF2CA921E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.PushGP", "HeuristicLab.Problems.ProgramSynthesis\HeuristicLab.Problems.PushGP.csproj", "{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}"
 EndProject
 Global
@@ -34,4 +36,8 @@
 		{22B5C087-CFC7-4D40-86C6-32FCF2CA921E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{22B5C087-CFC7-4D40-86C6-32FCF2CA921E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5C93448C-47E3-4C3F-B1D0-EE62A48C3204}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
