Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLab.GP.Interfaces-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLab.GP.Interfaces-3.3.csproj	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLab.GP.Interfaces-3.3.csproj	(revision 2210)
@@ -0,0 +1,122 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.GP.Interfaces</RootNamespace>
+    <AssemblyName>HeuristicLab.GP.Interfaces-3.3</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </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>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Xml.Linq">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data.DataSetExtensions">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="IFunctionTreeNameGenerator.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="IGeneticProgrammingModel.cs" />
+    <Compile Include="HeuristicLabGPInterfacesPlugin.cs" />
+    <Compile Include="IFunction.cs" />
+    <Compile Include="IFunctionTree.cs" />
+    <Compile Include="IFunctionTreeExporter.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
+      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
+      <Name>HeuristicLab.Core-3.2</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
+      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
+      <Name>HeuristicLab.PluginInfrastructure</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="HeuristicLab.snk" />
+    <None Include="Properties\AssemblyInfo.frame" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- 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>
+  -->
+  <PropertyGroup>
+    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd</PreBuildEvent>
+  </PropertyGroup>
+</Project>
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLabGPInterfacesPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLabGPInterfacesPlugin.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLabGPInterfacesPlugin.cs	(revision 2210)
@@ -0,0 +1,33 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.GP.Interfaces {
+  [ClassInfo(Name = "HeuristicLab.GP.Interfaces-3.3")]
+  [PluginFile(Filename = "HeuristicLab.GP.Interfaces-3.3.dll", Filetype = PluginFileType.Assembly)]
+  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
+  public class HeuristicLabGPInterfacesPlugin : PluginBase {
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunction.cs	(revision 2210)
@@ -0,0 +1,43 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.GP.Interfaces {
+  public interface IFunction : IItem {
+    string Name { get; }
+    IFunctionTree GetTreeNode();
+    ICollection<IFunction> GetAllowedSubFunctions(int index);
+    void AddAllowedSubFunction(IFunction f, int index);
+    void RemoveAllowedSubFunction(IFunction f, int index);
+    bool IsAllowedSubFunction(IFunction f, int index);
+    int MinArity { get; }
+    int MaxArity { get; }
+    int MinTreeHeight { get; }
+    int MinTreeSize { get; }
+    double Tickets { get; }
+    IOperator Initializer { get; }
+    IOperator Manipulator { get; }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTree.cs	(revision 2210)
@@ -0,0 +1,41 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.GP.Interfaces {
+  public interface IFunctionTree {
+    bool HasLocalParameters { get; }
+    IList<IFunctionTree> SubTrees { get; }
+    IFunction Function { get; }
+    IOperation CreateShakingOperation(IScope scope);
+    IOperation CreateInitOperation(IScope scope);
+    int GetSize();
+    int GetHeight();
+    void AddSubTree(IFunctionTree tree);
+    void InsertSubTree(int index, IFunctionTree tree);
+    void RemoveSubTree(int index);
+    IFunctionTree Clone();
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeExporter.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeExporter.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeExporter.cs	(revision 2210)
@@ -0,0 +1,33 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.GP.Interfaces {
+  public interface IFunctionTreeExporter {
+    string Name { get; }
+    string Export(IFunctionTree tree);
+    bool TryExport(IFunctionTree tree, out string exported);
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeNameGenerator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeNameGenerator.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTreeNameGenerator.cs	(revision 2210)
@@ -0,0 +1,32 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.GP.Interfaces {
+  public interface IFunctionTreeNameGenerator {
+    string Name { get; }
+    string GetName(IFunctionTree tree);
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IGeneticProgrammingModel.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IGeneticProgrammingModel.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/IGeneticProgrammingModel.cs	(revision 2210)
@@ -0,0 +1,33 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.GP.Interfaces {
+  public interface IGeneticProgrammingModel : IItem {
+    IFunctionTree FunctionTree { get; set; }
+    int Size { get; set; }
+    int Height { get; set; }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/Properties/AssemblyInfo.frame
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/Properties/AssemblyInfo.frame	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.Interfaces/3.3/Properties/AssemblyInfo.frame	(revision 2210)
@@ -0,0 +1,58 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using HeuristicLab.PluginInfrastructure;
+
+// 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.GP.Interfaces")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2008 HEAL")]
+[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("863021a4-3cde-48be-8af6-dac1077f5fb5")]
+
+// 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 Revision and Build Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.3.0.$WCREV$")]
+[assembly: AssemblyFileVersion("3.3.0.$WCREV$")]
+[assembly: AssemblyBuildDate("$WCNOW$")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj	(revision 2210)
@@ -110,4 +110,8 @@
       <Name>HeuristicLab.Data-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
       <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs	(revision 2210)
@@ -33,4 +33,5 @@
   [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
   [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.DataAnalysis;
 using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification.Classification {
@@ -63,5 +64,5 @@
       AddVariableInfo(new VariableInfo(SAMPLESEND, "The end of samples in the original dataset", typeof(IntData), VariableKind.In));
       AddVariableInfo(new VariableInfo(BESTMODELLSCOPE, "The variable containing the scope of the model (incl. meta data)", typeof(IScope), VariableKind.In));
-      AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(BakedFunctionTree), VariableKind.In));
+      AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(IGeneticProgrammingModel), VariableKind.In));
       AddVariableInfo(new VariableInfo(VOTES, "Array with the votes for each instance", typeof(IntMatrixData), VariableKind.New));
       AddVariableInfo(new VariableInfo(ACCURACY, "Accuracy of the one-vs-one multi-cass classifier", typeof(DoubleData), VariableKind.New));
@@ -82,8 +83,8 @@
         double classBValue = GetVariableValue<DoubleData>(CLASSBVALUE, childScope, true).Data;
         IScope bestScope = GetVariableValue<IScope>(BESTMODELLSCOPE, childScope, true);
-        BakedFunctionTree functionTree = GetVariableValue<BakedFunctionTree>(BESTMODELL, bestScope, true);
+        IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>(BESTMODELL, bestScope, true);
 
         BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
-        evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0, functionTree);
+        evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0, gpModel.FunctionTree);
         for(int i = 0; i < (samplesEnd - samplesStart); i++) {
           double est = evaluator.Evaluate(i + samplesStart);
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation-3.3.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation-3.3.csproj	(revision 2210)
@@ -104,4 +104,8 @@
       <Name>HeuristicLab.Data-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
       <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLabGPConditionalEvaluationPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLabGPConditionalEvaluationPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/HeuristicLabGPConditionalEvaluationPlugin.cs	(revision 2210)
@@ -32,4 +32,5 @@
   [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
   [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj	(revision 2210)
@@ -107,4 +107,8 @@
       <Name>HeuristicLab.Data-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
       <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLabGPTimeSeriesPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLabGPTimeSeriesPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLabGPTimeSeriesPlugin.cs	(revision 2210)
@@ -33,4 +33,5 @@
   [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
   [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs	(revision 2210)
@@ -36,4 +36,5 @@
 using HeuristicLab.Evolutionary;
 using HeuristicLab.Modeling;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -419,5 +420,5 @@
       Model model = new Model();
       Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
-      model.Data = bestModelScope.GetVariableValue<IFunctionTree>("FunctionTree", false);
+      model.Data = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("FunctionTree", false);
       model.Dataset = ds;
       model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data);
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs	(revision 2210)
@@ -30,9 +30,9 @@
 using HeuristicLab.Operators;
 using HeuristicLab.Random;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
   public sealed class Constant : Terminal {
     public const string VALUE = "Value";
-    private BakedFunctionTree constantNodeTemplate;
 
     public override string Description {
@@ -48,8 +48,4 @@
     public Constant()
       : base() {
-      DoubleData valueData = new DoubleData();
-      constantNodeTemplate = new BakedFunctionTree(this);
-      constantNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(VALUE, valueData));
-
       SetupInitialization();
       SetupManipulation();
@@ -57,5 +53,5 @@
 
     public override IFunctionTree GetTreeNode() {
-      return (IFunctionTree)constantNodeTemplate.Clone();
+      return new ConstantFunctionTree(this);
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ConstantFunctionTree.cs	(revision 2210)
@@ -0,0 +1,74 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP.StructureIdentification {
+  public class ConstantFunctionTree : FunctionTreeBase {
+    public double Value { get; set; }
+
+    public ConstantFunctionTree(Constant constant)
+      : base(constant) {
+    }
+
+    protected ConstantFunctionTree(ConstantFunctionTree original)
+      : base(original) {
+      Value = original.Value;
+    }
+
+    public override bool HasLocalParameters {
+      get {
+        return true;
+      }
+    }
+
+    public override IOperation CreateShakingOperation(IScope scope) {
+      Scope myVariableScope = new Scope();
+      scope.AddSubScope(myVariableScope);
+      myVariableScope.AddVariable(CreateValueVariable());
+      return new AtomicOperation(Function.Manipulator, myVariableScope);
+    }
+
+    public override IOperation CreateInitOperation(IScope scope) {
+      Scope myVariableScope = new Scope();
+      scope.AddSubScope(myVariableScope);
+      myVariableScope.AddVariable(CreateValueVariable());
+      return new AtomicOperation(Function.Initializer, myVariableScope);
+    }
+
+    public override IFunctionTree Clone() {
+      return new ConstantFunctionTree(this);
+    }
+
+    private IVariable CreateValueVariable() {
+      DoubleData data = new DoubleData(Value);
+      data.Changed += (sender, args) => Value = data.Data;
+      var variable = new HeuristicLab.Core.Variable(Constant.VALUE, data);
+      variable.ValueChanged += (sender, args) => Value = ((DoubleData)variable.Value).Data;
+      return variable;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.Operators;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -34,6 +35,5 @@
       : base() {
       AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IFunctionTree), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In));
       AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
@@ -51,7 +51,6 @@
       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
       Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-      IFunctionTree functionTree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
       double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-      int treeSize = scope.GetVariableValue<IntData>("TreeSize", true).Data;
       double totalEvaluatedNodes = scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data;
       int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
@@ -61,5 +60,5 @@
       bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true).Data;
       ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
-      evaluator.PrepareForEvaluation(dataset, targetVariable, trainingStart, trainingEnd, punishmentFactor, functionTree);
+      evaluator.PrepareForEvaluation(dataset, targetVariable, trainingStart, trainingEnd, punishmentFactor, gpModel.FunctionTree);
 
       double[] backupValues = null;
@@ -86,5 +85,5 @@
 
       // update the value of total evaluated nodes
-      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (end - start);
+      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + gpModel.Size * (end - start);
       return null;
     }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.DataAnalysis;
 using System.Linq;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -35,5 +36,5 @@
       : base() {
       AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IFunctionTree), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In));
       AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In));
       AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
@@ -43,7 +44,7 @@
     protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end) {
       ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
-      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
       double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-      evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree);
+      evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, gpModel.FunctionTree);
 
       double[] result = new double[end - start];
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.DataAnalysis;
 using System.Linq;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -35,5 +36,5 @@
       : base() {
       AddVariableInfo(new VariableInfo("TreeEvaluator", "The evaluator that should be used to evaluate the expression tree", typeof(ITreeEvaluator), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IFunctionTree), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be evaluated", typeof(IGeneticProgrammingModel), VariableKind.In));
       AddVariableInfo(new VariableInfo("TreeSize", "Size (number of nodes) of the tree to evaluate", typeof(IntData), VariableKind.In));
       AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
@@ -42,7 +43,7 @@
     protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end) {
       ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
-      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
       double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-      evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, tree);
+      evaluator.PrepareForEvaluation(dataset, targetVariable, start, end, punishmentFactor, gpModel.FunctionTree);
 
       double[,] result = new double[end - start, 2];
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs	(revision 2210)
@@ -29,4 +29,5 @@
 using HeuristicLab.Constraints;
 using StructId = HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/GreaterThan.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/GreaterThan.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/GreaterThan.cs	(revision 2210)
@@ -35,4 +35,5 @@
 
     public GreaterThan() : base() { }
+
   }
 }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2210)
@@ -86,10 +86,9 @@
     <Compile Include="Average.cs" />
     <Compile Include="BakedTreeEvaluator.cs" />
-    <Compile Include="BaseClasses\BinaryFunction.cs" />
-    <Compile Include="BaseClasses\Terminal.cs" />
-    <Compile Include="BaseClasses\UnaryFunction.cs" />
     <Compile Include="Constant.cs" />
     <Compile Include="AlgorithmBase.cs" />
+    <Compile Include="ConstantFunctionTree.cs" />
     <Compile Include="Evaluators\SimpleGPEvaluatorBase.cs" />
+    <Compile Include="VariableFunctionTree.cs" />
     <Compile Include="TreeEvaluatorBase.cs" />
     <Compile Include="HL2TreeEvaluator.cs" />
@@ -168,4 +167,8 @@
       <Name>HeuristicLab.Evolutionary-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.GP\3.3\HeuristicLab.GP-3.3.csproj">
       <Project>{1F1CF3ED-374C-4288-995B-93F6B872F571}</Project>
@@ -221,4 +224,7 @@
     <None Include="HeuristicLab.snk" />
     <None Include="Properties\AssemblyInfo.frame" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="BaseClasses\" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLabGPStructureIdentificationPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLabGPStructureIdentificationPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLabGPStructureIdentificationPlugin.cs	(revision 2210)
@@ -34,4 +34,5 @@
   [Dependency(Dependency = "HeuristicLab.Evolutionary-3.2")]
   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.Logging-3.2")]
   [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using System.Diagnostics;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs	(revision 2210)
@@ -25,4 +25,5 @@
 using System.Text;
 using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -120,11 +121,5 @@
 
     public static string ExportToHL2(this Constant constant, IFunctionTree tree) {
-      HeuristicLab.Core.IItem constantItem = tree.GetLocalVariable(Constant.VALUE).Value;
-      double value;
-      if (constantItem is ConstrainedDoubleData) {
-        value = ((ConstrainedDoubleData)constantItem).Data;
-      } else {
-        value = ((DoubleData)constantItem).Data;
-      }
+      double value = ((ConstantFunctionTree)tree).Value;
       return "[T]Constant(" + value.ToString("r") + ";0;0)";
     }
@@ -135,15 +130,6 @@
 
     public static string ExportToHL2(this Differential differential, IFunctionTree tree) {
-      HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value;
-      double weight;
-      if (weightItem is ConstrainedDoubleData) {
-        weight = ((ConstrainedDoubleData)weightItem).Data;
-      } else {
-        weight = ((DoubleData)weightItem).Data;
-      }
-      var index = tree.GetLocalVariable(Differential.INDEX).Value;
-      var offset = ((ConstrainedDoubleData)tree.GetLocalVariable(Differential.OFFSET).Value).Data;
-
-      return "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
+      var varTree = (VariableFunctionTree)tree;
+      return "[T]Differential(" + varTree.Weight.ToString("r") + ";" + varTree.VariableName + ";" + -varTree.SampleOffset + ")";
     }
 
@@ -189,15 +175,6 @@
 
     public static string ExportToHL2(this Variable variable, IFunctionTree tree) {
-      HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value;
-      double weight;
-      if (weightItem is ConstrainedDoubleData) {
-        weight = ((ConstrainedDoubleData)weightItem).Data;
-      } else {
-        weight = ((DoubleData)weightItem).Data;
-      }
-      string index = ((StringData)tree.GetLocalVariable(Variable.INDEX).Value).Data;
-      double offset = ((ConstrainedIntData)tree.GetLocalVariable(Variable.OFFSET).Value).Data;
-
-      return "[T]Variable(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
+      var varTree = (VariableFunctionTree)tree;
+      return "[T]Variable(" + varTree.Weight.ToString("r") + ";" + varTree.VariableName + ";" + -varTree.SampleOffset + ")";
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs	(revision 2210)
@@ -159,5 +159,4 @@
       StandardCrossOver crossover = new StandardCrossOver();
       crossover.Name = "Crossover";
-      crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       return crossover;
     }
@@ -166,5 +165,4 @@
       ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();
       treeCreator.Name = "Tree generator";
-      treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       treeCreator.GetVariableInfo("MinTreeSize").ActualName = "MinInitialTreeSize";
       return treeCreator;
@@ -183,18 +181,12 @@
       StochasticMultiBranch multibranch = new StochasticMultiBranch();
       FullTreeShaker fullTreeShaker = new FullTreeShaker();
-      fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       fullTreeShaker.GetVariableInfo("ShakingFactor").ActualName = "FullTreeShakingFactor";
 
       OnePointShaker onepointShaker = new OnePointShaker();
-      onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       onepointShaker.GetVariableInfo("ShakingFactor").ActualName = "OnePointShakingFactor";
       ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();
-      changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation();
-      cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation();
-      deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
       SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation();
-      substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
 
       IOperator[] manipulators = new IOperator[] {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolTable.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolTable.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolTable.cs	(revision 2210)
@@ -26,4 +26,5 @@
 using HeuristicLab.Core;
 using System.Xml;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs	(revision 2210)
@@ -25,4 +25,5 @@
 using System.Text;
 using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -125,5 +126,5 @@
 
     public static string ExportToScheme(this Constant constant, IFunctionTree tree) {
-      return tree.GetLocalVariable(Constant.VALUE).Value.ToString();
+      return ((ConstantFunctionTree)tree).Value.ToString("r");
     }
 
@@ -173,10 +174,12 @@
 
     public static string ExportToScheme(this Variable variable, IFunctionTree tree) {
-      return "(variable " + tree.GetLocalVariable(Variable.WEIGHT).Value + " " +
-        tree.GetLocalVariable(Variable.INDEX).Value + " " + tree.GetLocalVariable(Variable.OFFSET).Value + ")";
+      var varTree = (VariableFunctionTree)tree;
+      return "(variable " + varTree.Weight.ToString("r") + " " +
+        varTree.VariableName + " " + varTree.SampleOffset + ")";
     }
     public static string ExportToScheme(this Differential differential, IFunctionTree tree) {
-      return "(differential " + tree.GetLocalVariable(Differential.WEIGHT).Value + " " +
-        tree.GetLocalVariable(Differential.INDEX).Value + " " + tree.GetLocalVariable(Differential.OFFSET).Value + ")";
+      var varTree = (VariableFunctionTree)tree;
+      return "(differential " + varTree.Weight.ToString("r") + " " +
+        varTree.VariableName + " " + varTree.SampleOffset + ")";
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs	(revision 2210)
@@ -29,4 +29,5 @@
 using HeuristicLab.DataAnalysis;
 using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -45,5 +46,4 @@
       public byte arity;
       public byte symbol;
-      public IFunction function;
     }
 
@@ -61,34 +61,40 @@
       minValue = mean - punishmentFactor * range;
 
-      BakedFunctionTree bakedTree = functionTree as BakedFunctionTree;
-      if (bakedTree == null) throw new ArgumentException("TreeEvaluators can only evaluate BakedFunctionTrees");
-
-      List<LightWeightFunction> linearRepresentation = bakedTree.LinearRepresentation;
-      codeArr = new Instr[linearRepresentation.Count];
+      codeArr = new Instr[functionTree.GetSize()];
       int i = 0;
-      foreach (LightWeightFunction f in linearRepresentation) {
-        codeArr[i++] = TranslateToInstr(f);
+      foreach (IFunctionTree tree in IteratePrefix(functionTree)) {
+        codeArr[i++] = TranslateToInstr(tree);
       }
     }
 
-    private Instr TranslateToInstr(LightWeightFunction f) {
+    private IEnumerable<IFunctionTree> IteratePrefix(IFunctionTree functionTree) {
+      List<IFunctionTree> prefixForm = new List<IFunctionTree>();
+      prefixForm.Add(functionTree);
+      foreach (IFunctionTree subTree in functionTree.SubTrees) {
+        prefixForm.AddRange(IteratePrefix(subTree));
+      }
+      return prefixForm;
+    }
+
+    private Instr TranslateToInstr(IFunctionTree tree) {
       Instr instr = new Instr();
-      instr.arity = f.arity;
-      instr.symbol = EvaluatorSymbolTable.MapFunction(f.functionType);
+      instr.arity = (byte)tree.SubTrees.Count;
+      instr.symbol = EvaluatorSymbolTable.MapFunction(tree.Function);
       switch (instr.symbol) {
         case EvaluatorSymbolTable.DIFFERENTIAL:
         case EvaluatorSymbolTable.VARIABLE: {
-            instr.i_arg0 = (short)dataset.GetVariableIndex((((StringData)f.localData[1].Value).Data)); // var
-            instr.d_arg0 = ((DoubleData)f.localData[0].Value).Data; // weight
-            instr.i_arg1 = (short)((ConstrainedIntData)f.localData[2].Value).Data; // sample-offset
+            VariableFunctionTree varTree = (VariableFunctionTree)tree;
+            instr.i_arg0 = (short)dataset.GetVariableIndex(varTree.VariableName);
+            instr.d_arg0 = varTree.Weight;
+            instr.i_arg1 = (short)varTree.SampleOffset;
             break;
           }
         case EvaluatorSymbolTable.CONSTANT: {
-            instr.d_arg0 = ((DoubleData)f.localData[0].Value).Data; // value
+            ConstantFunctionTree constTree = (ConstantFunctionTree)tree;
+            instr.d_arg0 = constTree.Value;
             break;
           }
         case EvaluatorSymbolTable.UNKNOWN: {
-            instr.function = f.functionType;
-            break;
+            throw new NotSupportedException("Unknown function symbol: " + instr.symbol);
           }
       }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Random;
 using HeuristicLab.Operators;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -35,7 +36,5 @@
     public const string WEIGHT = "Weight";
     public const string OFFSET = "SampleOffset";
-    public const string INDEX = "Variable";
-
-    private BakedFunctionTree variableNodeTemplate;
+    public const string VARIABLENAME = "Variable";
 
     private int minOffset;
@@ -50,33 +49,10 @@
     }
 
-    public override IEnumerable<string> LocalParameterNames {
-      get {
-        return new string[] { WEIGHT, OFFSET, INDEX };
-      }
-    }
-
     public override IFunctionTree GetTreeNode() {
-      return (IFunctionTree)variableNodeTemplate.Clone();
+      return new VariableFunctionTree(this);
     }
 
     public Variable()
       : base() {
-      //AddVariableInfo(new VariableInfo(INDEX, "The variable name", typeof(StringData), VariableKind.None));
-      //GetVariableInfo(INDEX).Local = true;
-      //AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(DoubleData), VariableKind.None));
-      //GetVariableInfo(WEIGHT).Local = true;
-      //AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None));
-      //GetVariableInfo(OFFSET).Local = true;
-      variableNodeTemplate = new BakedFunctionTree(this);
-
-      DoubleData weight = new DoubleData();
-      variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));
-
-      StringData variable = new StringData();
-      variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
-
-      ConstrainedIntData sampleOffset = new ConstrainedIntData();
-      variableNodeTemplate.AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset));
-
       SetupInitialization();
       SetupManipulation();
@@ -87,5 +63,5 @@
       SequentialProcessor seq = new SequentialProcessor();
       UniformItemChooser variableRandomizer = new UniformItemChooser();
-      variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;
+      variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME;
       variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
       variableRandomizer.Name = "Variable randomizer";
@@ -117,5 +93,5 @@
       SequentialProcessor seq = new SequentialProcessor();
       UniformItemChooser variableRandomizer = new UniformItemChooser();
-      variableRandomizer.GetVariableInfo("Value").ActualName = INDEX;
+      variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME;
       variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
       variableRandomizer.Name = "Variable randomizer";
@@ -143,28 +119,6 @@
 
     public void SetConstraints(int minSampleOffset, int maxSampleOffset) {
-      ConstrainedIntData offset = (ConstrainedIntData)variableNodeTemplate.GetLocalVariable(OFFSET).Value;
-      IntBoundedConstraint offsetConstraint = new IntBoundedConstraint();
       this.minOffset = minSampleOffset;
       this.maxOffset = maxSampleOffset;
-      offsetConstraint.LowerBound = minSampleOffset;
-      offsetConstraint.LowerBoundEnabled = true;
-      offsetConstraint.LowerBoundIncluded = true;
-      offsetConstraint.UpperBound = maxSampleOffset;
-      offsetConstraint.UpperBoundEnabled = true;
-      offsetConstraint.UpperBoundIncluded = true;
-      offset.AddConstraint(offsetConstraint);
-
-      //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);
-      //IntBoundedConstraint indexConstraint = new IntBoundedConstraint();
-      //minIndex = minInputIndex;
-      //maxIndex = maxInputIndex;
-      //indexConstraint.LowerBound = minInputIndex;
-      //indexConstraint.LowerBoundEnabled = true;
-      //indexConstraint.LowerBoundIncluded = true;
-      //indexConstraint.UpperBound = maxInputIndex;
-      //indexConstraint.UpperBoundEnabled = true;
-      //indexConstraint.UpperBoundIncluded = true;
-      //index.AddConstraint(indexConstraint);
-
       SetupInitialization();
       SetupManipulation();
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/VariableFunctionTree.cs	(revision 2210)
@@ -0,0 +1,98 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP.StructureIdentification {
+  public class VariableFunctionTree : FunctionTreeBase {
+    public double Weight { get; set; }
+    public string VariableName { get; set; }
+    public int SampleOffset { get; set; }
+
+    public VariableFunctionTree(Variable variable)
+      : base(variable) {
+    }
+
+    protected VariableFunctionTree(VariableFunctionTree original)
+      : base(original) {
+      Weight = original.Weight;
+      VariableName = original.VariableName;
+      SampleOffset = original.SampleOffset;
+    }
+
+    public override bool HasLocalParameters {
+      get {
+        return true;
+      }
+    }
+
+    public override IOperation CreateShakingOperation(IScope scope) {
+      Scope myVariableScope = new Scope();
+      scope.AddSubScope(myVariableScope);
+      myVariableScope.AddVariable(CreateWeightVariable());
+      myVariableScope.AddVariable(CreateVariableNameVariable());
+      myVariableScope.AddVariable(CreateSampleOffsetVariable());
+      return new AtomicOperation(Function.Manipulator, myVariableScope);
+    }
+
+    public override IOperation CreateInitOperation(IScope scope) {
+      Scope myVariableScope = new Scope();
+      scope.AddSubScope(myVariableScope); 
+      myVariableScope.AddVariable(CreateWeightVariable());
+      myVariableScope.AddVariable(CreateVariableNameVariable());
+      myVariableScope.AddVariable(CreateSampleOffsetVariable());
+      return new AtomicOperation(Function.Initializer, myVariableScope);
+    }
+
+    public override IFunctionTree Clone() {
+      return new VariableFunctionTree(this);
+    }
+
+    private IVariable CreateSampleOffsetVariable() {
+      IntData data = new IntData(SampleOffset);
+      data.Changed += (sender, args) => SampleOffset = data.Data;
+      var variable = new HeuristicLab.Core.Variable(Variable.OFFSET, data);
+      variable.ValueChanged += (sender, args) => SampleOffset = ((IntData)variable.Value).Data;
+      return variable;
+    }
+
+    private IVariable CreateVariableNameVariable() {
+      StringData data = new StringData(VariableName);
+      data.Changed += (sender, args) => VariableName = data.Data;
+      var variable = new HeuristicLab.Core.Variable(Variable.VARIABLENAME, data);
+      variable.ValueChanged += (sender, args) => VariableName = ((StringData)variable.Value).Data;
+      return variable;
+    }
+
+    private IVariable CreateWeightVariable() {
+      DoubleData data = new DoubleData(Weight);
+      data.Changed += (sender, args) => Weight = data.Data;
+      var variable = new HeuristicLab.Core.Variable(Variable.WEIGHT, data);
+      variable.ValueChanged += (sender, args) => Weight = ((DoubleData)variable.Value).Data;
+      return variable;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BakedFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BakedFunctionTree.cs	(revision 2202)
+++ 	(revision )
@@ -1,368 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using System.Xml;
-using System.Globalization;
-
-namespace HeuristicLab.GP {
-
-  public class LightWeightFunction {
-    public byte arity = 0;
-    public IFunction functionType;
-    public List<IVariable> localData = new List<IVariable>();
-
-    public LightWeightFunction Clone() {
-      LightWeightFunction clone = new LightWeightFunction();
-      clone.arity = arity;
-      clone.functionType = functionType;
-      clone.localData = localData.Select(v=>(IVariable)v.Clone()).ToList();
-      return clone;
-    }
-  }
-
-  public class BakedFunctionTree : ItemBase, IFunctionTree {
-    private List<LightWeightFunction> linearRepresentation;
-    public List<LightWeightFunction> LinearRepresentation {
-      get {
-        FlattenVariables();
-        FlattenTrees();
-        return linearRepresentation;
-      }
-    }
-    private bool treesExpanded = false;
-    private List<IFunctionTree> subTrees;
-    private bool variablesExpanded = false;
-    private List<IVariable> variables = new List<IVariable>();
-
-    public IOperator Initializer {
-      get { return Function.Initializer; }
-    }
-
-    public IOperator Manipulator {
-      get { return Function.Manipulator; }
-    }
-
-    public BakedFunctionTree() {
-      linearRepresentation = new List<LightWeightFunction>();
-    }
-
-    public BakedFunctionTree(IFunction function)
-      : this() {
-      LightWeightFunction fun = new LightWeightFunction();
-      fun.functionType = function;
-      linearRepresentation.Add(fun);
-      treesExpanded = true;
-      subTrees = new List<IFunctionTree>();
-      variables = new List<IVariable>();
-      variablesExpanded = true;
-    }
-
-    //internal BakedFunctionTree(IFunctionTree tree)
-    //  : this() {
-    //  LightWeightFunction fun = new LightWeightFunction();
-    //  fun.functionType = tree.Function;
-    //  linearRepresentation.Add(fun);
-    //  foreach (IVariable variable in tree.LocalVariables) {
-    //    IObjectData value = (IObjectData)variable.Value;
-    //    fun.localData.Add(value.Data);
-    //  }
-    //  foreach (IFunctionTree subTree in tree.SubTrees) {
-    //    AddSubTree(new BakedFunctionTree(subTree));
-    //  }
-    //}
-
-    private int BranchLength(int branchRoot) {
-      int arity = linearRepresentation[branchRoot].arity;
-      int length = 1;
-      for (int i = 0; i < arity; i++) {
-        length += BranchLength(branchRoot + length);
-      }
-      return length;
-    }
-
-    private void FlattenTrees() {
-      if (treesExpanded) {
-        linearRepresentation[0].arity = (byte)subTrees.Count;
-        foreach (BakedFunctionTree subTree in subTrees) {
-          subTree.FlattenVariables();
-          subTree.FlattenTrees();
-          linearRepresentation.AddRange(subTree.linearRepresentation);
-        }
-        treesExpanded = false;
-        subTrees = null;
-      }
-    }
-
-    private void FlattenVariables() {
-      if (variablesExpanded) {
-        linearRepresentation[0].localData.Clear();
-        foreach (IVariable variable in variables) {
-          //object objData = variable.Value;
-          //while (objData is IObjectData) objData = ((IObjectData)objData).Data;
-          //linearRepresentation[0].localData[variable.Name] = objData;
-          linearRepresentation[0].localData.Add(variable);
-        }
-        variablesExpanded = false;
-        variables = null;
-      }
-    }
-
-    public int Size {
-      get {
-        if (treesExpanded) {
-          int size = 1;
-          foreach (BakedFunctionTree tree in subTrees) {
-            size += tree.Size;
-          }
-          return size;
-        } else
-          return linearRepresentation.Count;
-      }
-    }
-
-    public int Height {
-      get {
-        if (treesExpanded) {
-          int height = 0;
-          foreach (IFunctionTree subTree in subTrees) {
-            int curHeight = subTree.Height;
-            if (curHeight > height) height = curHeight;
-          }
-          return height + 1;
-        } else {
-          int nextBranchStart;
-          return BranchHeight(0, out nextBranchStart);
-        }
-      }
-    }
-
-    private int BranchHeight(int branchStart, out int nextBranchStart) {
-      LightWeightFunction f = linearRepresentation[branchStart];
-      int height = 0;
-      branchStart++;
-      for (int i = 0; i < f.arity; i++) {
-        int curHeight = BranchHeight(branchStart, out nextBranchStart);
-        if (curHeight > height) height = curHeight;
-        branchStart = nextBranchStart;
-      }
-      nextBranchStart = branchStart;
-      return height + 1;
-    }
-
-    public IList<IFunctionTree> SubTrees {
-      get {
-        if (!treesExpanded) {
-          subTrees = new List<IFunctionTree>();
-          int arity = linearRepresentation[0].arity;
-          int branchIndex = 1;
-          for (int i = 0; i < arity; i++) {
-            BakedFunctionTree subTree = new BakedFunctionTree();
-            int length = BranchLength(branchIndex);
-            for (int j = branchIndex; j < branchIndex + length; j++) {
-              subTree.linearRepresentation.Add(linearRepresentation[j]);
-            }
-            branchIndex += length;
-            subTrees.Add(subTree);
-          }
-          treesExpanded = true;
-          linearRepresentation.RemoveRange(1, linearRepresentation.Count - 1);
-          linearRepresentation[0].arity = 0;
-        }
-        return subTrees;
-      }
-    }
-
-    public ICollection<IVariable> LocalVariables {
-      get {
-        if (!variablesExpanded) {
-          variables = new List<IVariable>();
-          IFunction function = Function;          
-          //int localVariableIndex = 0;
-          foreach (IVariable v in linearRepresentation[0].localData) {
-            //IObjectData objData = (IObjectData)clone.Value;
-            //if (objData is ConstrainedDoubleData) {
-            //  ((ConstrainedDoubleData)objData).Data = (double)linearRepresentation[0].localData[localVariableIndex];
-            //} else if (objData is ConstrainedIntData) {
-            //  ((ConstrainedIntData)objData).Data = (int)linearRepresentation[0].localData[localVariableIndex];
-            //} else {
-            //  objData.Data = linearRepresentation[0].localData[localVariableIndex];
-            //}
-            variables.Add(v);
-            //localVariableIndex++;
-          }
-          variablesExpanded = true;
-          linearRepresentation[0].localData.Clear();
-        }
-        return variables;
-      }
-    }
-
-    public IFunction Function {
-      get { return linearRepresentation[0].functionType; }
-    }
-
-    public IVariable GetLocalVariable(string name) {
-      foreach (IVariable var in LocalVariables) {
-        if (var.Name == name) return var;
-      }
-      return null;
-    }
-
-    public void AddVariable(IVariable variable) {
-      if (!variablesExpanded) throw new InvalidOperationException();
-      if (!variables.Exists(v => v.Name == variable.Name))
-        variables.Add(variable);
-    }
-
-    public void RemoveVariable(string name) {
-      if (!variablesExpanded) throw new InvalidOperationException();
-      variables.RemoveAll(v => v.Name == name);
-    }
-
-    public void AddSubTree(IFunctionTree tree) {
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.Add(tree);
-    }
-
-    public void InsertSubTree(int index, IFunctionTree tree) {
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.Insert(index, tree);
-    }
-
-    public void RemoveSubTree(int index) {
-      // sanity check
-      if (!treesExpanded) throw new InvalidOperationException();
-      subTrees.RemoveAt(index);
-    }
-
-    //public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
-    //  FlattenVariables();
-    //  FlattenTrees();
-    //  XmlNode node = base.GetXmlNode(name, document, persistedObjects);
-    //  XmlNode linearRepresentationNode = document.CreateElement("LinearRepresentation");
-    //  foreach (LightWeightFunction f in linearRepresentation) {
-    //    XmlNode entryNode = PersistenceManager.Persist("Function", f.functionType, document, persistedObjects);
-    //    XmlAttribute arityAttribute = document.CreateAttribute("Arity");
-    //    arityAttribute.Value = XmlConvert.ToString(f.arity);
-    //    entryNode.Attributes.Append(arityAttribute);
-    //    foreach (object o in f.localData) {
-    //      if (f.localData.Count > 0) {
-    //        entryNode.AppendChild(CreateDataNode(document, o));
-    //      }
-    //    }
-    //    linearRepresentationNode.AppendChild(entryNode);
-    //  }
-
-    //  node.AppendChild(linearRepresentationNode);
-    //  return node;
-    //}
-
-    private XmlNode CreateDataNode(XmlDocument doc, object o) {
-      XmlNode node = doc.CreateElement("Data");
-      XmlAttribute typeAttr = doc.CreateAttribute("Type");
-      node.Attributes.Append(typeAttr);
-      if (o is double) {
-        node.Value = XmlConvert.ToString((double)o);
-        typeAttr.Value = "d";
-      } else if (o is int) {
-        node.Value = XmlConvert.ToString((int)o);
-        typeAttr.Value = "i";
-      } else if (o is string) {
-        node.Value = (string)o;
-        typeAttr.Value = "s";
-      } else throw new ArgumentException("Invalid type for local data element: " + o);
-      return node;
-    }
-
-    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
-    //  base.Populate(node, restoredObjects);
-    //  XmlNode linearRepresentationNode = node.SelectSingleNode("LinearRepresentation");
-    //  foreach (XmlNode entryNode in linearRepresentationNode.ChildNodes) {
-    //    LightWeightFunction f = new LightWeightFunction();
-    //    f.arity = XmlConvert.ToByte(entryNode.Attributes["Arity"].Value);
-    //    foreach (XmlNode dataNode in entryNode.ChildNodes) {
-    //      f.localData.Add(ParseDataNode(dataNode));
-    //    }
-    //    f.functionType = (IFunction)PersistenceManager.Restore(entryNode, restoredObjects);
-    //    linearRepresentation.Add(f);
-    //  }
-    //  treesExpanded = false;
-    //  variablesExpanded = false;
-    //}
-
-    private object ParseDataNode(XmlNode dataNode) {
-      string type = dataNode.Attributes["Type"].Value;
-      if (type == "d") {
-        return XmlConvert.ToDouble(dataNode.Value);
-      } else if (type == "i") {
-        return XmlConvert.ToInt32(dataNode.Value);
-      } else if (type == "s") {
-        return dataNode.Value;
-      } else throw new FormatException("Can't parse type \"" + type + "\" \"" + dataNode.Value + "\" as local data for GP trees");
-    }
-
-    //private string GetString(IEnumerable<double> xs) {
-    //  StringBuilder builder = new StringBuilder();
-    //  foreach (double x in xs) {
-    //    builder.Append(x.ToString("r", CultureInfo.InvariantCulture) + "; ");
-    //  }
-    //  if (builder.Length > 0) builder.Remove(builder.Length - 2, 2);
-    //  return builder.ToString();
-    //}
-
-    //private List<T> GetList<T>(string s, Converter<string, T> converter) {
-    //  List<T> result = new List<T>();
-    //  string[] tokens = s.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
-    //  foreach (string token in tokens) {
-    //    T x = converter(token.Trim());
-    //    result.Add(x);
-    //  }
-    //  return result;
-    //}
-
-    public override object Clone(IDictionary<Guid, object> clonedObjects) {
-      BakedFunctionTree clone = new BakedFunctionTree();
-      // in case the user (de)serialized the tree between evaluation and selection we have to flatten the tree again.
-      if (treesExpanded) FlattenTrees();
-      if (variablesExpanded) FlattenVariables();
-      foreach (LightWeightFunction f in linearRepresentation) {
-        clone.linearRepresentation.Add(f.Clone());
-      }
-      return clone;
-    }
-
-    public override IView CreateView() {
-      return new FunctionTreeView(this);
-    }
-
-    //public override string ToString() {
-    //  SymbolicExpressionExporter exporter = new SymbolicExpressionExporter();
-    //  exporter.Visit(this);
-    //  return exporter.GetStringRepresentation();
-    //}
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BakedFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BakedFunctionTree.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BakedFunctionTree.cs	(revision 2210)
@@ -0,0 +1,368 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using System.Xml;
+using System.Globalization;
+
+namespace HeuristicLab.GP {
+
+  public class LightWeightFunction {
+    public byte arity = 0;
+    public IFunction functionType;
+    public List<IVariable> localData = new List<IVariable>();
+
+    public LightWeightFunction Clone() {
+      LightWeightFunction clone = new LightWeightFunction();
+      clone.arity = arity;
+      clone.functionType = functionType;
+      clone.localData = localData.Select(v=>(IVariable)v.Clone()).ToList();
+      return clone;
+    }
+  }
+
+  public class BakedFunctionTree : ItemBase, IFunctionTree {
+    private List<LightWeightFunction> linearRepresentation;
+    public List<LightWeightFunction> LinearRepresentation {
+      get {
+        FlattenVariables();
+        FlattenTrees();
+        return linearRepresentation;
+      }
+    }
+    private bool treesExpanded = false;
+    private List<IFunctionTree> subTrees;
+    private bool variablesExpanded = false;
+    private List<IVariable> variables = new List<IVariable>();
+
+    public IOperator Initializer {
+      get { return Function.Initializer; }
+    }
+
+    public IOperator Manipulator {
+      get { return Function.Manipulator; }
+    }
+
+    public BakedFunctionTree() {
+      linearRepresentation = new List<LightWeightFunction>();
+    }
+
+    public BakedFunctionTree(IFunction function)
+      : this() {
+      LightWeightFunction fun = new LightWeightFunction();
+      fun.functionType = function;
+      linearRepresentation.Add(fun);
+      treesExpanded = true;
+      subTrees = new List<IFunctionTree>();
+      variables = new List<IVariable>();
+      variablesExpanded = true;
+    }
+
+    //internal BakedFunctionTree(IFunctionTree tree)
+    //  : this() {
+    //  LightWeightFunction fun = new LightWeightFunction();
+    //  fun.functionType = tree.Function;
+    //  linearRepresentation.Add(fun);
+    //  foreach (IVariable variable in tree.LocalVariables) {
+    //    IObjectData value = (IObjectData)variable.Value;
+    //    fun.localData.Add(value.Data);
+    //  }
+    //  foreach (IFunctionTree subTree in tree.SubTrees) {
+    //    AddSubTree(new BakedFunctionTree(subTree));
+    //  }
+    //}
+
+    private int BranchLength(int branchRoot) {
+      int arity = linearRepresentation[branchRoot].arity;
+      int length = 1;
+      for (int i = 0; i < arity; i++) {
+        length += BranchLength(branchRoot + length);
+      }
+      return length;
+    }
+
+    private void FlattenTrees() {
+      if (treesExpanded) {
+        linearRepresentation[0].arity = (byte)subTrees.Count;
+        foreach (BakedFunctionTree subTree in subTrees) {
+          subTree.FlattenVariables();
+          subTree.FlattenTrees();
+          linearRepresentation.AddRange(subTree.linearRepresentation);
+        }
+        treesExpanded = false;
+        subTrees = null;
+      }
+    }
+
+    private void FlattenVariables() {
+      if (variablesExpanded) {
+        linearRepresentation[0].localData.Clear();
+        foreach (IVariable variable in variables) {
+          //object objData = variable.Value;
+          //while (objData is IObjectData) objData = ((IObjectData)objData).Data;
+          //linearRepresentation[0].localData[variable.Name] = objData;
+          linearRepresentation[0].localData.Add(variable);
+        }
+        variablesExpanded = false;
+        variables = null;
+      }
+    }
+
+    public int Size {
+      get {
+        if (treesExpanded) {
+          int size = 1;
+          foreach (BakedFunctionTree tree in subTrees) {
+            size += tree.Size;
+          }
+          return size;
+        } else
+          return linearRepresentation.Count;
+      }
+    }
+
+    public int Height {
+      get {
+        if (treesExpanded) {
+          int height = 0;
+          foreach (IFunctionTree subTree in subTrees) {
+            int curHeight = subTree.Height;
+            if (curHeight > height) height = curHeight;
+          }
+          return height + 1;
+        } else {
+          int nextBranchStart;
+          return BranchHeight(0, out nextBranchStart);
+        }
+      }
+    }
+
+    private int BranchHeight(int branchStart, out int nextBranchStart) {
+      LightWeightFunction f = linearRepresentation[branchStart];
+      int height = 0;
+      branchStart++;
+      for (int i = 0; i < f.arity; i++) {
+        int curHeight = BranchHeight(branchStart, out nextBranchStart);
+        if (curHeight > height) height = curHeight;
+        branchStart = nextBranchStart;
+      }
+      nextBranchStart = branchStart;
+      return height + 1;
+    }
+
+    public IList<IFunctionTree> SubTrees {
+      get {
+        if (!treesExpanded) {
+          subTrees = new List<IFunctionTree>();
+          int arity = linearRepresentation[0].arity;
+          int branchIndex = 1;
+          for (int i = 0; i < arity; i++) {
+            BakedFunctionTree subTree = new BakedFunctionTree();
+            int length = BranchLength(branchIndex);
+            for (int j = branchIndex; j < branchIndex + length; j++) {
+              subTree.linearRepresentation.Add(linearRepresentation[j]);
+            }
+            branchIndex += length;
+            subTrees.Add(subTree);
+          }
+          treesExpanded = true;
+          linearRepresentation.RemoveRange(1, linearRepresentation.Count - 1);
+          linearRepresentation[0].arity = 0;
+        }
+        return subTrees;
+      }
+    }
+
+    public ICollection<IVariable> LocalVariables {
+      get {
+        if (!variablesExpanded) {
+          variables = new List<IVariable>();
+          IFunction function = Function;          
+          //int localVariableIndex = 0;
+          foreach (IVariable v in linearRepresentation[0].localData) {
+            //IObjectData objData = (IObjectData)clone.Value;
+            //if (objData is ConstrainedDoubleData) {
+            //  ((ConstrainedDoubleData)objData).Data = (double)linearRepresentation[0].localData[localVariableIndex];
+            //} else if (objData is ConstrainedIntData) {
+            //  ((ConstrainedIntData)objData).Data = (int)linearRepresentation[0].localData[localVariableIndex];
+            //} else {
+            //  objData.Data = linearRepresentation[0].localData[localVariableIndex];
+            //}
+            variables.Add(v);
+            //localVariableIndex++;
+          }
+          variablesExpanded = true;
+          linearRepresentation[0].localData.Clear();
+        }
+        return variables;
+      }
+    }
+
+    public IFunction Function {
+      get { return linearRepresentation[0].functionType; }
+    }
+
+    public IVariable GetLocalVariable(string name) {
+      foreach (IVariable var in LocalVariables) {
+        if (var.Name == name) return var;
+      }
+      return null;
+    }
+
+    public void AddVariable(IVariable variable) {
+      if (!variablesExpanded) throw new InvalidOperationException();
+      if (!variables.Exists(v => v.Name == variable.Name))
+        variables.Add(variable);
+    }
+
+    public void RemoveVariable(string name) {
+      if (!variablesExpanded) throw new InvalidOperationException();
+      variables.RemoveAll(v => v.Name == name);
+    }
+
+    public void AddSubTree(IFunctionTree tree) {
+      if (!treesExpanded) throw new InvalidOperationException();
+      subTrees.Add(tree);
+    }
+
+    public void InsertSubTree(int index, IFunctionTree tree) {
+      if (!treesExpanded) throw new InvalidOperationException();
+      subTrees.Insert(index, tree);
+    }
+
+    public void RemoveSubTree(int index) {
+      // sanity check
+      if (!treesExpanded) throw new InvalidOperationException();
+      subTrees.RemoveAt(index);
+    }
+
+    //public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
+    //  FlattenVariables();
+    //  FlattenTrees();
+    //  XmlNode node = base.GetXmlNode(name, document, persistedObjects);
+    //  XmlNode linearRepresentationNode = document.CreateElement("LinearRepresentation");
+    //  foreach (LightWeightFunction f in linearRepresentation) {
+    //    XmlNode entryNode = PersistenceManager.Persist("Function", f.functionType, document, persistedObjects);
+    //    XmlAttribute arityAttribute = document.CreateAttribute("Arity");
+    //    arityAttribute.Value = XmlConvert.ToString(f.arity);
+    //    entryNode.Attributes.Append(arityAttribute);
+    //    foreach (object o in f.localData) {
+    //      if (f.localData.Count > 0) {
+    //        entryNode.AppendChild(CreateDataNode(document, o));
+    //      }
+    //    }
+    //    linearRepresentationNode.AppendChild(entryNode);
+    //  }
+
+    //  node.AppendChild(linearRepresentationNode);
+    //  return node;
+    //}
+
+    private XmlNode CreateDataNode(XmlDocument doc, object o) {
+      XmlNode node = doc.CreateElement("Data");
+      XmlAttribute typeAttr = doc.CreateAttribute("Type");
+      node.Attributes.Append(typeAttr);
+      if (o is double) {
+        node.Value = XmlConvert.ToString((double)o);
+        typeAttr.Value = "d";
+      } else if (o is int) {
+        node.Value = XmlConvert.ToString((int)o);
+        typeAttr.Value = "i";
+      } else if (o is string) {
+        node.Value = (string)o;
+        typeAttr.Value = "s";
+      } else throw new ArgumentException("Invalid type for local data element: " + o);
+      return node;
+    }
+
+    //public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
+    //  base.Populate(node, restoredObjects);
+    //  XmlNode linearRepresentationNode = node.SelectSingleNode("LinearRepresentation");
+    //  foreach (XmlNode entryNode in linearRepresentationNode.ChildNodes) {
+    //    LightWeightFunction f = new LightWeightFunction();
+    //    f.arity = XmlConvert.ToByte(entryNode.Attributes["Arity"].Value);
+    //    foreach (XmlNode dataNode in entryNode.ChildNodes) {
+    //      f.localData.Add(ParseDataNode(dataNode));
+    //    }
+    //    f.functionType = (IFunction)PersistenceManager.Restore(entryNode, restoredObjects);
+    //    linearRepresentation.Add(f);
+    //  }
+    //  treesExpanded = false;
+    //  variablesExpanded = false;
+    //}
+
+    private object ParseDataNode(XmlNode dataNode) {
+      string type = dataNode.Attributes["Type"].Value;
+      if (type == "d") {
+        return XmlConvert.ToDouble(dataNode.Value);
+      } else if (type == "i") {
+        return XmlConvert.ToInt32(dataNode.Value);
+      } else if (type == "s") {
+        return dataNode.Value;
+      } else throw new FormatException("Can't parse type \"" + type + "\" \"" + dataNode.Value + "\" as local data for GP trees");
+    }
+
+    //private string GetString(IEnumerable<double> xs) {
+    //  StringBuilder builder = new StringBuilder();
+    //  foreach (double x in xs) {
+    //    builder.Append(x.ToString("r", CultureInfo.InvariantCulture) + "; ");
+    //  }
+    //  if (builder.Length > 0) builder.Remove(builder.Length - 2, 2);
+    //  return builder.ToString();
+    //}
+
+    //private List<T> GetList<T>(string s, Converter<string, T> converter) {
+    //  List<T> result = new List<T>();
+    //  string[] tokens = s.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
+    //  foreach (string token in tokens) {
+    //    T x = converter(token.Trim());
+    //    result.Add(x);
+    //  }
+    //  return result;
+    //}
+
+    public override object Clone(IDictionary<Guid, object> clonedObjects) {
+      BakedFunctionTree clone = new BakedFunctionTree();
+      // in case the user (de)serialized the tree between evaluation and selection we have to flatten the tree again.
+      if (treesExpanded) FlattenTrees();
+      if (variablesExpanded) FlattenVariables();
+      foreach (LightWeightFunction f in linearRepresentation) {
+        clone.linearRepresentation.Add(f.Clone());
+      }
+      return clone;
+    }
+
+    public override IView CreateView() {
+      return new FunctionTreeView(this);
+    }
+
+    //public override string ToString() {
+    //  SymbolicExpressionExporter exporter = new SymbolicExpressionExporter();
+    //  exporter.Visit(this);
+    //  return exporter.GetStringRepresentation();
+    //}
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/BinaryFunction.cs	(revision 2210)
@@ -0,0 +1,35 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Constraints;
+
+namespace HeuristicLab.GP {
+  public abstract class BinaryFunction : FunctionBase {
+    public BinaryFunction()
+      : base() {
+      MinArity = 2; MaxArity = 2;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs	(revision 2210)
@@ -0,0 +1,214 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+using System.Xml;
+using HeuristicLab.Constraints;
+using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP {
+  public abstract class FunctionBase : ItemBase, IFunction {
+    private List<List<IFunction>> allowedSubFunctions = new List<List<IFunction>>();
+    private int minArity = -1;
+    private int maxArity = -1;
+    private double tickets = 1.0;
+    private IOperator initializer;
+    private IOperator manipulator;
+    private int minTreeHeight = -1;
+    private int minTreeSize = -1;
+
+    public virtual string Name {
+      get { return this.GetType().Name; }
+    }
+
+    public virtual string Description {
+      get { return "Description for this function is missing (TODO)"; }
+    }
+
+    public int MinArity {
+      get {
+        return minArity;
+      }
+      protected set {
+        minArity = value;
+        while (minArity > allowedSubFunctions.Count) allowedSubFunctions.Add(new List<IFunction>());
+      }
+    }
+
+    public int MaxArity {
+      get {
+        return maxArity;
+      }
+      protected set {
+        maxArity = value;
+        while (allowedSubFunctions.Count > maxArity) allowedSubFunctions.RemoveAt(allowedSubFunctions.Count - 1);
+        while (maxArity > allowedSubFunctions.Count) allowedSubFunctions.Add(new List<IFunction>());
+      }
+    }
+
+
+    public int MinTreeSize {
+      get {
+        if (minTreeSize <= 0) RecalculateMinimalTreeSize();
+        return minTreeSize;
+      }
+    }
+
+    public int MinTreeHeight {
+      get {
+        if (minTreeHeight <= 0) RecalculateMinimalTreeHeight();
+        return minTreeHeight;
+      }
+    }
+
+    public double Tickets {
+      get { return tickets; }
+      set {
+        if (value < 0.0) throw new ArgumentException("Number of tickets must be positive");
+        else tickets = value;
+      }
+    }
+
+    public IOperator Initializer {
+      get { return initializer; }
+      set { initializer = value; }
+    }
+
+    public IOperator Manipulator {
+      get { return manipulator; }
+      set { manipulator = value; }
+    }
+
+    public virtual IEnumerable<string> LocalParameterNames {
+      get { return new string[0]; }
+    }
+
+    public virtual IFunctionTree GetTreeNode() {
+      return new FunctionTreeBase(this);
+    }
+
+    //private List<IConstraint> constraints = new List<IConstraint>();
+    //public ICollection<IConstraint> Constraints {
+    //  get { return constraints; }
+    //}
+
+    //private void RefreshArity() {
+    //  minArity = 2; maxArity = 2; // default arity is 2
+    //  foreach (IConstraint constraint in Constraints) {
+    //    NumberOfSubOperatorsConstraint theConstraint = constraint as NumberOfSubOperatorsConstraint;
+    //    if (theConstraint != null) {
+    //      minArity = theConstraint.MinOperators.Data;
+    //      maxArity = theConstraint.MaxOperators.Data;
+    //    }
+    //  }
+    //}
+
+    public ICollection<IFunction> GetAllowedSubFunctions(int index) {
+      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      //if (allowedSubFunctions == null) {
+      //  // first time: analyze the constraint and create a cached copy of the allowed sub-functions
+      //  allowedSubFunctions = new List<IFunction>[MaxArity];
+      //  for (int i = 0; i < MaxArity; i++) {
+      //    allowedSubFunctions[i] = GetAllowedSubFunctions(i);
+      //  }
+      //}
+      return allowedSubFunctions[index];
+    }
+
+    public void AddAllowedSubFunction(IFunction function, int index) {
+      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      if (allowedSubFunctions[index] == null) {
+        allowedSubFunctions[index] = new List<IFunction>();
+      }
+      if (!allowedSubFunctions[index].Contains(function)) {
+        allowedSubFunctions[index].Add(function);
+      }
+    }
+
+    public void RemoveAllowedSubFunction(IFunction function, int index) {
+      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
+      allowedSubFunctions[index].Add(function);
+    }
+
+    public bool IsAllowedSubFunction(IFunction function, int index) {
+      return GetAllowedSubFunctions(index).Contains(function);
+    }
+
+    //private List<IFunction> GetAllowedSubFunctions(int index) {
+    //  List<IFunction> allowedSubFunctions = new List<IFunction>();
+    //  foreach (IConstraint constraint in Constraints) {
+    //    if (constraint is SubOperatorTypeConstraint) {
+    //      SubOperatorTypeConstraint subOpConstraint = constraint as SubOperatorTypeConstraint;
+    //      if (subOpConstraint.SubOperatorIndex.Data == index) {
+    //        foreach (IFunction f in subOpConstraint.AllowedSubOperators) allowedSubFunctions.Add(f);
+    //        subOpConstraint.Changed += new EventHandler(subOpConstraint_Changed); // register an event-handler to invalidate the cache on constraint changes
+    //        return allowedSubFunctions;
+    //      }
+    //    } else if (constraint is AllSubOperatorsTypeConstraint) {
+    //      AllSubOperatorsTypeConstraint subOpConstraint = constraint as AllSubOperatorsTypeConstraint;
+    //      foreach (IFunction f in subOpConstraint.AllowedSubOperators) allowedSubFunctions.Add(f);
+    //      subOpConstraint.Changed += new EventHandler(subOpConstraint_Changed); // register an event-handler to invalidate the cache on constraint changes
+    //      return allowedSubFunctions;
+    //    }
+    //  }
+    //  return allowedSubFunctions;
+    //}
+
+    //private void subOpConstraint_Changed(object sender, EventArgs e) {
+    //  allowedSubFunctions = null;
+    //}
+
+    public override IView CreateView() {
+      return new FunView(this);
+    }
+
+    private void RecalculateMinimalTreeSize() {
+      minTreeSize = int.MaxValue;
+      int sum = 1;
+      int minSize = int.MaxValue;
+      for (int i = 0; i < MinArity; i++) {
+        foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
+          minSize = Math.Min(minSize, subFun.MinTreeSize);
+        }
+        sum += minSize;
+      }
+      minTreeSize = sum;
+    }
+
+    private void RecalculateMinimalTreeHeight() {
+      minTreeHeight = int.MaxValue;
+      int height = 0;
+      int minHeight = int.MaxValue;
+      for (int i = 0; i < MinArity; i++) {
+        foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
+          minHeight = Math.Min(minHeight, subFun.MinTreeHeight);
+        }
+        height = Math.Max(height, minHeight);
+      }
+      minTreeHeight = height + 1;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs	(revision 2210)
@@ -0,0 +1,97 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP {
+  public class FunctionTreeBase : IFunctionTree {
+    private List<IFunctionTree> subTrees;
+    private IFunction function;
+
+    public FunctionTreeBase(IFunction function) {
+      subTrees = new List<IFunctionTree>();
+      this.function = function;
+    }
+
+    protected FunctionTreeBase(FunctionTreeBase original) {
+      this.function = original.Function;
+      this.subTrees = new List<IFunctionTree>(original.SubTrees.Count);
+      foreach (IFunctionTree originalSubTree in original.SubTrees) {
+        this.SubTrees.Add(originalSubTree.Clone());
+      }
+    }
+
+    #region IFunctionTree Members
+    public virtual bool HasLocalParameters {
+      get { return false; }
+    }
+
+    public IList<IFunctionTree> SubTrees {
+      get { return subTrees; }
+    }
+
+    public IFunction Function {
+      get { return function; }
+    }
+
+    public int GetSize() {
+      int size = 1;
+      foreach (IFunctionTree tree in subTrees) size += tree.GetSize();
+      return size;
+    }
+
+    public int GetHeight() {
+      int maxHeight = 0;
+      foreach (IFunctionTree tree in subTrees) maxHeight = Math.Max(maxHeight, tree.GetHeight());
+      return maxHeight + 1;
+    }
+
+    public virtual IOperation CreateShakingOperation(IScope scope) {
+      return null;
+    }
+
+    public virtual IOperation CreateInitOperation(IScope scope) {
+      return null;
+    }
+
+    public void AddSubTree(IFunctionTree tree) {
+      subTrees.Add(tree);
+    }
+
+    public void InsertSubTree(int index, IFunctionTree tree) {
+      subTrees.Insert(index, tree);
+    }
+
+    public void RemoveSubTree(int index) {
+      subTrees.RemoveAt(index);
+    }
+
+    public virtual IFunctionTree Clone() {
+      return new FunctionTreeBase(this);
+    }
+
+    #endregion
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/Terminal.cs	(revision 2210)
@@ -0,0 +1,35 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Constraints;
+
+namespace HeuristicLab.GP {
+  public abstract class Terminal : FunctionBase {
+    public Terminal()
+      : base() {
+      MinArity = 0; MaxArity = 0;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/UnaryFunction.cs	(revision 2210)
@@ -0,0 +1,35 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Constraints;
+
+namespace HeuristicLab.GP {
+  public abstract class UnaryFunction : FunctionBase {
+    public UnaryFunction()
+      : base() {
+      MinArity = 1; MaxArity = 1;
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/DefaultFunctionTreeNameGenerator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/DefaultFunctionTreeNameGenerator.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/DefaultFunctionTreeNameGenerator.cs	(revision 2210)
@@ -24,4 +24,5 @@
 using System.Text;
 using HeuristicLab.Core;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunView.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunView.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunView.cs	(revision 2210)
@@ -8,4 +8,5 @@
 using System.Windows.Forms;
 using HeuristicLab.Core;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionBase.cs	(revision 2202)
+++ 	(revision )
@@ -1,214 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Data;
-using HeuristicLab.Core;
-using System.Xml;
-using HeuristicLab.Constraints;
-using System.Diagnostics;
-
-namespace HeuristicLab.GP {
-  public abstract class FunctionBase : ItemBase, IFunction {
-    private List<List<IFunction>> allowedSubFunctions = new List<List<IFunction>>();
-    private int minArity = -1;
-    private int maxArity = -1;
-    private double tickets = 1.0;
-    private IOperator initializer;
-    private IOperator manipulator;
-    private int minTreeHeight = -1;
-    private int minTreeSize = -1;
-
-    public virtual string Name {
-      get { return this.GetType().Name; }
-    }
-
-    public virtual string Description {
-      get { return "Description for this function is missing (TODO)"; }
-    }
-
-    public int MinArity {
-      get {
-        return minArity;
-      }
-      protected set {
-        minArity = value;
-        while (minArity > allowedSubFunctions.Count) allowedSubFunctions.Add(new List<IFunction>());
-      }
-    }
-
-    public int MaxArity {
-      get {
-        return maxArity;
-      }
-      protected set {
-        maxArity = value;
-        while (allowedSubFunctions.Count > maxArity) allowedSubFunctions.RemoveAt(allowedSubFunctions.Count - 1);
-        while (maxArity > allowedSubFunctions.Count) allowedSubFunctions.Add(new List<IFunction>());
-      }
-    }
-
-
-    public int MinTreeSize {
-      get {
-        if (minTreeSize <= 0) RecalculateMinimalTreeSize();
-        return minTreeSize;
-      }
-    }
-
-    public int MinTreeHeight {
-      get {
-        if (minTreeHeight <= 0) RecalculateMinimalTreeHeight();
-        return minTreeHeight;
-      }
-    }
-
-    public double Tickets {
-      get { return tickets; }
-      set {
-        if (value < 0.0) throw new ArgumentException("Number of tickets must be positive");
-        else tickets = value;
-      }
-    }
-
-    public IOperator Initializer {
-      get { return initializer; }
-      set { initializer = value; }
-    }
-
-    public IOperator Manipulator {
-      get { return manipulator; }
-      set { manipulator = value; }
-    }
-
-    public virtual IEnumerable<string> LocalParameterNames {
-      get { return new string[0]; }
-    }
-
-    public virtual IFunctionTree GetTreeNode() {
-      return new BakedFunctionTree(this);
-    }
-
-
-    //private List<IConstraint> constraints = new List<IConstraint>();
-    //public ICollection<IConstraint> Constraints {
-    //  get { return constraints; }
-    //}
-
-    //private void RefreshArity() {
-    //  minArity = 2; maxArity = 2; // default arity is 2
-    //  foreach (IConstraint constraint in Constraints) {
-    //    NumberOfSubOperatorsConstraint theConstraint = constraint as NumberOfSubOperatorsConstraint;
-    //    if (theConstraint != null) {
-    //      minArity = theConstraint.MinOperators.Data;
-    //      maxArity = theConstraint.MaxOperators.Data;
-    //    }
-    //  }
-    //}
-
-    public ICollection<IFunction> GetAllowedSubFunctions(int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
-      //if (allowedSubFunctions == null) {
-      //  // first time: analyze the constraint and create a cached copy of the allowed sub-functions
-      //  allowedSubFunctions = new List<IFunction>[MaxArity];
-      //  for (int i = 0; i < MaxArity; i++) {
-      //    allowedSubFunctions[i] = GetAllowedSubFunctions(i);
-      //  }
-      //}
-      return allowedSubFunctions[index];
-    }
-
-    public void AddAllowedSubFunction(IFunction function, int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
-      if (allowedSubFunctions[index] == null) {
-        allowedSubFunctions[index] = new List<IFunction>();
-      }
-      if (!allowedSubFunctions[index].Contains(function)) {
-        allowedSubFunctions[index].Add(function);
-      }
-    }
-
-    public void RemoveAllowedSubFunction(IFunction function, int index) {
-      if (index < 0 || index > MaxArity) throw new ArgumentException("Index outside of allowed range. index = " + index);
-      allowedSubFunctions[index].Add(function);
-    }
-
-    public bool IsAllowedSubFunction(IFunction function, int index) {
-      return GetAllowedSubFunctions(index).Contains(function);
-    }
-
-    //private List<IFunction> GetAllowedSubFunctions(int index) {
-    //  List<IFunction> allowedSubFunctions = new List<IFunction>();
-    //  foreach (IConstraint constraint in Constraints) {
-    //    if (constraint is SubOperatorTypeConstraint) {
-    //      SubOperatorTypeConstraint subOpConstraint = constraint as SubOperatorTypeConstraint;
-    //      if (subOpConstraint.SubOperatorIndex.Data == index) {
-    //        foreach (IFunction f in subOpConstraint.AllowedSubOperators) allowedSubFunctions.Add(f);
-    //        subOpConstraint.Changed += new EventHandler(subOpConstraint_Changed); // register an event-handler to invalidate the cache on constraint changes
-    //        return allowedSubFunctions;
-    //      }
-    //    } else if (constraint is AllSubOperatorsTypeConstraint) {
-    //      AllSubOperatorsTypeConstraint subOpConstraint = constraint as AllSubOperatorsTypeConstraint;
-    //      foreach (IFunction f in subOpConstraint.AllowedSubOperators) allowedSubFunctions.Add(f);
-    //      subOpConstraint.Changed += new EventHandler(subOpConstraint_Changed); // register an event-handler to invalidate the cache on constraint changes
-    //      return allowedSubFunctions;
-    //    }
-    //  }
-    //  return allowedSubFunctions;
-    //}
-
-    //private void subOpConstraint_Changed(object sender, EventArgs e) {
-    //  allowedSubFunctions = null;
-    //}
-
-    public override IView CreateView() {
-      return new FunView(this);
-    }
-
-    private void RecalculateMinimalTreeSize() {
-      minTreeSize = int.MaxValue;
-      int sum = 1;
-      int minSize = int.MaxValue;
-      for (int i = 0; i < MinArity; i++) {
-        foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
-          minSize = Math.Min(minSize, subFun.MinTreeSize);
-        }
-        sum += minSize;
-      }
-      minTreeSize = sum;
-    }
-
-    private void RecalculateMinimalTreeHeight() {
-      minTreeHeight = int.MaxValue;
-      int height = 0;
-      int minHeight = int.MaxValue;
-      for (int i = 0; i < MinArity; i++) {
-        foreach (IFunction subFun in GetAllowedSubFunctions(i)) {
-          minHeight = Math.Min(minHeight, subFun.MinTreeHeight);
-        }
-        height = Math.Max(height, minHeight);
-      }
-      minTreeHeight = height + 1;
-    }
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionGroup.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionGroup.cs	(revision 2202)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Operators;
-using HeuristicLab.Data;
-using HeuristicLab.Random;
-using HeuristicLab.Constraints;
-
-namespace HeuristicLab.GP {
-  public class FunctionGroup : StorableBase {
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibrary.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibrary.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibrary.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Constraints;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs	(revision 2210)
@@ -33,4 +33,5 @@
 using HeuristicLab.Operators;
 using HeuristicLab.Random;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionTreeView.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionTreeView.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/FunctionTreeView.cs	(revision 2210)
@@ -31,4 +31,5 @@
 using HeuristicLab.PluginInfrastructure;
 using HeuristicLab.Data;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -136,5 +137,5 @@
       if (funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
         IFunctionTree selectedBranch = (IFunctionTree)funTreeView.SelectedNode.Tag;
-        UpdateVariablesList(selectedBranch);
+//      UpdateVariablesList(selectedBranch);
         templateTextBox.Text = nameGenerator.GetName(selectedBranch);
         this.selectedBranch = selectedBranch;
@@ -143,27 +144,27 @@
     }
 
-    private void UpdateVariablesList(IFunctionTree functionTree) {
-      foreach (IVariable variable in functionTree.LocalVariables) {
-        variablesListBox.Items.Add(variable.Name);
-      }
-    }
+    //private void UpdateVariablesList(IFunctionTree functionTree) {
+    //  foreach (IVariable variable in functionTree.LocalVariables) {
+    //    variablesListBox.Items.Add(variable.Name);
+    //  }
+    //}
 
     private void variablesListBox_SelectedIndexChanged(object sender, EventArgs e) {
-      // in case we had an event-handler registered for a different variable => unregister the event-handler
-      if (selectedVariable != null) {
-        selectedVariable.Value.Changed -= new EventHandler(selectedVariable_ValueChanged);
-      }
-      if (variablesListBox.SelectedItem != null) {
-        string selectedVariableName = (string)variablesListBox.SelectedItem;
-        selectedVariable = selectedBranch.GetLocalVariable(selectedVariableName);
-        variablesSplitContainer.Panel2.Controls.Clear();
-        Control editor = (Control)selectedVariable.CreateView();
-        variablesSplitContainer.Panel2.Controls.Add(editor);
-        editor.Dock = DockStyle.Fill;
-        // register an event handler that updates the treenode when the value of the variable is changed by the user
-        selectedVariable.Value.Changed += new EventHandler(selectedVariable_ValueChanged);
-      } else {
-        variablesSplitContainer.Panel2.Controls.Clear();
-      }
+      //// in case we had an event-handler registered for a different variable => unregister the event-handler
+      //if (selectedVariable != null) {
+      //  selectedVariable.Value.Changed -= new EventHandler(selectedVariable_ValueChanged);
+      //}
+      //if (variablesListBox.SelectedItem != null) {
+      //  string selectedVariableName = (string)variablesListBox.SelectedItem;
+      //  selectedVariable = selectedBranch.GetLocalVariable(selectedVariableName);
+      //  variablesSplitContainer.Panel2.Controls.Clear();
+      //  Control editor = (Control)selectedVariable.CreateView();
+      //  variablesSplitContainer.Panel2.Controls.Add(editor);
+      //  editor.Dock = DockStyle.Fill;
+      //  // register an event handler that updates the treenode when the value of the variable is changed by the user
+      //  selectedVariable.Value.Changed += new EventHandler(selectedVariable_ValueChanged);
+      //} else {
+      //  variablesSplitContainer.Panel2.Controls.Clear();
+      //}
     }
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/GeneticProgrammingModel.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/GeneticProgrammingModel.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/GeneticProgrammingModel.cs	(revision 2210)
@@ -0,0 +1,70 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP {
+  public class GeneticProgrammingModel : ItemBase, IGeneticProgrammingModel {
+    private IFunctionTree functionTree;
+    public IFunctionTree FunctionTree {
+      get {
+        return functionTree;
+      }
+      set {
+        functionTree = value;
+        Size = functionTree.GetSize();
+        Height = functionTree.GetHeight();
+      }
+    }
+    public int Size { get; set; }
+    public int Height { get; set; }
+
+    public GeneticProgrammingModel()
+      : base() {
+    }
+
+    public GeneticProgrammingModel(IFunctionTree tree) : base() {
+      FunctionTree = tree;
+    }
+
+    public override object Clone(IDictionary<Guid, object> clonedObjects) {
+      GeneticProgrammingModel clone = (GeneticProgrammingModel)base.Clone(clonedObjects);
+      clone.FunctionTree = FunctionTree.Clone();
+      return clone;
+    }
+
+    public override System.Xml.XmlNode GetXmlNode(string name, System.Xml.XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
+      throw new NotImplementedException();
+    }
+
+    public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
+      throw new NotImplementedException();
+    }
+
+    public override IView CreateView() {
+      return new FunctionTreeView(this.FunctionTree);
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj	(revision 2210)
@@ -82,5 +82,9 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="BakedFunctionTree.cs" />
+    <Compile Include="BaseClasses\BinaryFunction.cs" />
+    <Compile Include="BaseClasses\FunctionBase.cs" />
+    <Compile Include="BaseClasses\FunctionTreeBase.cs" />
+    <Compile Include="BaseClasses\Terminal.cs" />
+    <Compile Include="BaseClasses\UnaryFunction.cs" />
     <Compile Include="FunctionLibrary.cs" />
     <Compile Include="FunctionLibraryEditor.cs">
@@ -102,4 +106,8 @@
       <DependentUpon>FunView.cs</DependentUpon>
     </Compile>
+    <Compile Include="GeneticProgrammingModel.cs" />
+    <Compile Include="Initialization\ProbabilisticTreeCreator.cs" />
+    <Compile Include="Initialization\RampedTreeCreator.cs" />
+    <Compile Include="Manipulation\GPManipulatorBase.cs" />
     <Compile Include="TrainingWindowSlider.cs" />
     <Compile Include="DefaultFunctionTreeNameGenerator.cs" />
@@ -111,10 +119,5 @@
     <Compile Include="Recombination\UniformCrossover.cs" />
     <Compile Include="UnknownFunctionException.cs" />
-    <Compile Include="IFunctionTreeNameGenerator.cs" />
-    <Compile Include="IFunctionTreeExporter.cs" />
-    <Compile Include="FunctionBase.cs" />
     <Compile Include="HeuristicLabGPPlugin.cs" />
-    <Compile Include="IFunction.cs" />
-    <Compile Include="IFunctionTree.cs" />
     <Compile Include="Manipulation\ChangeNodeTypeManipulation.cs" />
     <Compile Include="Manipulation\CutOutNodeManipulation.cs" />
@@ -123,7 +126,5 @@
     <Compile Include="Manipulation\OnePointShaker.cs" />
     <Compile Include="Manipulation\SubstituteSubTreeManipulation.cs" />
-    <Compile Include="ProbabilisticTreeCreator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="RampedTreeCreator.cs" />
     <Compile Include="Recombination\LangdonHomologousCrossOver.cs" />
     <Compile Include="Recombination\OnePointCrossOver.cs" />
@@ -148,4 +149,8 @@
       <Project>{F5614C53-153C-4A37-A608-121E1C087F07}</Project>
       <Name>HeuristicLab.Evolutionary-3.2</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
     </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Operators\3.2\HeuristicLab.Operators-3.2.csproj">
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLabGPPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLabGPPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/HeuristicLabGPPlugin.cs	(revision 2210)
@@ -28,4 +28,5 @@
   [ClassInfo(Name = "HeuristicLab.GP-3.3")]
   [PluginFile(Filename = "HeuristicLab.GP-3.3.dll", Filetype = PluginFileType.Assembly)]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.Constraints-3.2")]
   [Dependency(Dependency = "HeuristicLab.Core-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunction.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunction.cs	(revision 2202)
+++ 	(revision )
@@ -1,44 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.GP {
-  public interface IFunction : IItem {
-    string Name { get; }
-    IFunctionTree GetTreeNode();
-    ICollection<IFunction> GetAllowedSubFunctions(int index);
-    void AddAllowedSubFunction(IFunction f, int index);
-    void RemoveAllowedSubFunction(IFunction f, int index);
-    bool IsAllowedSubFunction(IFunction f, int index);
-    int MinArity { get; }
-    int MaxArity { get; }
-    int MinTreeHeight { get; }
-    int MinTreeSize { get; }
-    double Tickets { get; }
-    IEnumerable<string> LocalParameterNames { get; }
-    IOperator Initializer { get; }
-    IOperator Manipulator { get; }
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTree.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTree.cs	(revision 2202)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.GP {
-  public interface IFunctionTree : IItem {
-    int Size { get; }
-    int Height { get; }
-    IList<IFunctionTree> SubTrees { get; }
-    ICollection<IVariable> LocalVariables { get; }
-    IFunction Function { get; }
-    IOperator Manipulator { get; }
-    IOperator Initializer { get; }
-    IVariable GetLocalVariable(string name);
-    void AddVariable(IVariable variable);
-    void RemoveVariable(string name);
-    void AddSubTree(IFunctionTree tree);
-    void InsertSubTree(int index, IFunctionTree tree);
-    void RemoveSubTree(int index);
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTreeExporter.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTreeExporter.cs	(revision 2202)
+++ 	(revision )
@@ -1,33 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.GP {
-  public interface IFunctionTreeExporter {
-    string Name { get; }
-    string Export(IFunctionTree tree);
-    bool TryExport(IFunctionTree tree, out string exported);
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTreeNameGenerator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/IFunctionTreeNameGenerator.cs	(revision 2202)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.GP {
-  public interface IFunctionTreeNameGenerator {
-    string Name { get; }
-    string GetName(IFunctionTree tree);
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/ProbabilisticTreeCreator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/ProbabilisticTreeCreator.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/ProbabilisticTreeCreator.cs	(revision 2210)
@@ -0,0 +1,75 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using System;
+using HeuristicLab.Random;
+using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
+using System.Collections.Generic;
+
+namespace HeuristicLab.GP {
+  public class ProbabilisticTreeCreator : OperatorBase {
+    private int MAX_TRIES { get { return 100; } }
+
+    public override string Description {
+      get { return @"Generates a new random operator tree."; }
+    }
+
+    public ProbabilisticTreeCreator()
+      : base() {
+      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "The function library containing all available functions", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MinTreeSize", "The minimal allowed size of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IGeneticProgrammingModel), VariableKind.New | VariableKind.Out));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
+      FunctionLibrary funLibrary = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
+      int minTreeSize = GetVariableValue<IntData>("MinTreeSize", scope, true).Data;
+      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
+      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
+
+      int treeSize = random.Next(minTreeSize, maxTreeSize + 1);
+      IFunctionTree root;
+      int tries = 0;
+      TreeGardener gardener = new TreeGardener(random, funLibrary);
+      do {
+        root = gardener.PTC2(treeSize, maxTreeHeight);
+        if (tries++ >= MAX_TRIES) {
+          // try a different size
+          treeSize = random.Next(minTreeSize, maxTreeSize + 1);
+          tries = 0;
+        }
+      } while (root.GetSize() > maxTreeSize || root.GetHeight() > maxTreeHeight);
+
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), new GeneticProgrammingModel(root)));
+      return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(root), scope);
+    }
+
+ }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/RampedTreeCreator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/RampedTreeCreator.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Initialization/RampedTreeCreator.cs	(revision 2210)
@@ -0,0 +1,72 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using System;
+using HeuristicLab.Random;
+using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP {
+  public class RampedTreeCreator : OperatorBase {
+    public override string Description {
+      get { return @"Generates a new random operator tree."; }
+    }
+
+    public RampedTreeCreator()
+      : base() {
+      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "The function library containing all available functions", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MinTreeHeight", "The minimal allowed height of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IGeneticProgrammingModel), VariableKind.New | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
+      FunctionLibrary opLibrary = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
+      int minTreeHeight = GetVariableValue<IntData>("MinTreeHeight", scope, true).Data;
+      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
+      double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data;
+
+      TreeGardener gardener = new TreeGardener(random, opLibrary);
+
+      int treeHeight = random.Next(minTreeHeight, maxTreeHeight + 1);
+      IFunctionTree root;
+      if(random.NextDouble() <= balancedTreesRate) {
+        root = gardener.CreateBalancedRandomTree(Int32.MaxValue, treeHeight);
+      } else {
+        root = gardener.CreateUnbalancedRandomTree(Int32.MaxValue, treeHeight);
+      }
+
+      Debug.Assert(gardener.IsValidTree(root) && root.GetHeight() <= maxTreeHeight);
+
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), new GeneticProgrammingModel(root)));
+      return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(root), scope);
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Logging/TreeArityAnalyser.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Logging/TreeArityAnalyser.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Logging/TreeArityAnalyser.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -43,5 +44,5 @@
     public TreeArityAnalyser()
       : base() {
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to analyse", typeof(IGeneticProgrammingModel), VariableKind.In));
       AddVariableInfo(new VariableInfo("Histogram", "The histogram of arities over all functions in all functiontrees", typeof(ItemList<ItemList<IntData>>), VariableKind.New | VariableKind.Out));
     }
@@ -69,7 +70,7 @@
 
     private ItemList<ItemList<IntData>> GetArityHistogram(IScope subScope) {
-      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", subScope, false);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", subScope, false);
       List<int> arities = new List<int>();
-      Arities(tree, arities);
+      Arities(gpModel.FunctionTree, arities);
       var histogram = arities.GroupBy(x => x, (g, xs) => new { Group = g, Count = xs.Count() }).OrderBy(g=>g.Group); // count number of distinct arities
       ItemList<ItemList<IntData>> result = new ItemList<ItemList<IntData>>();
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs	(revision 2210)
@@ -30,7 +30,8 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
-  public class ChangeNodeTypeManipulation : OperatorBase {
+  public class ChangeNodeTypeManipulation : GPManipulatorBase {
 
     public override string Description {
@@ -44,29 +45,14 @@
     public ChangeNodeTypeManipulation()
       : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
     }
 
-
-    public override IOperation Apply(IScope scope) {
-      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
-      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      IntData treeSize = GetVariableValue<IntData>("TreeSize", scope, false);
-      IntData treeHeight = GetVariableValue<IntData>("TreeHeight", scope, false);
-      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
-      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
+    internal override IOperation Manipulate(MersenneTwister random, IGeneticProgrammingModel gpModel, FunctionLibrary library, int maxTreeSize, int maxTreeHeight, IScope scope) {
       TreeGardener gardener = new TreeGardener(random, library);
-      IFunctionTree parent = gardener.GetRandomParentNode(root);
+      IFunctionTree parent = gardener.GetRandomParentNode(gpModel.FunctionTree);
       IFunctionTree selectedChild;
       int selectedChildIndex;
-      if(parent == null) {
+      if (parent == null) {
         selectedChildIndex = 0;
-        selectedChild = root;
+        selectedChild = gpModel.FunctionTree;
       } else {
         selectedChildIndex = random.Next(parent.SubTrees.Count);
@@ -74,10 +60,9 @@
       }
 
-      if(selectedChild.SubTrees.Count == 0) {
+      if (selectedChild.SubTrees.Count == 0) {
         IFunctionTree newTerminal = ChangeTerminalType(parent, selectedChild, selectedChildIndex, gardener, random);
-        if(parent == null) {
+        if (parent == null) {
           // no parent means the new child is the initial operator
-          // and we have to update the value in the variable
-          scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTerminal;
+          gpModel.FunctionTree = newTerminal;
         } else {
           parent.RemoveSubTree(selectedChildIndex);
@@ -85,8 +70,8 @@
           // updating the variable is not necessary because it stays the same
         }
-        Debug.Assert(gardener.IsValidTree(root));
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
         // size and height stays the same when changing a terminal so no need to update the variables
         // schedule an operation to initialize the new terminal
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTerminal), scope);
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newTerminal), scope);
       } else {
         List<IFunctionTree> uninitializedBranches;
@@ -95,18 +80,16 @@
         // calculate the height and size difference and 
         // check if the size of the new tree is still in the allowed bounds
-        int oldChildSize = selectedChild.Size;
-        int oldChildHeight = selectedChild.Height;
-        int newChildSize = newFunctionTree.Size;
-        int newChildHeight = newFunctionTree.Height;
-        if((treeHeight.Data - oldChildHeight) + newChildHeight > maxTreeHeight ||
-          (treeSize.Data - oldChildSize) + newChildSize > maxTreeSize) {
+        int oldChildSize = selectedChild.GetSize();
+        int oldChildHeight = selectedChild.GetHeight();
+        int newChildSize = newFunctionTree.GetSize();
+        int newChildHeight = newFunctionTree.GetHeight();
+        if ((gpModel.Height - oldChildHeight) + newChildHeight > maxTreeHeight ||
+          (gpModel.Size - oldChildSize) + newChildSize > maxTreeSize) {
           // if size-constraints are violated don't change anything
           return null;
         }
-        if(parent == null) {
+        if (parent == null) {
           // no parent means the new function is the initial operator
-          // and we have to update the value in the variable
-          scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newFunctionTree;
-          root = newFunctionTree;
+          gpModel.FunctionTree = newFunctionTree;
         } else {
           // remove the old child
@@ -116,13 +99,12 @@
         }
         // update size and height
-        treeSize.Data = (treeSize.Data - oldChildSize) + newChildSize;
-        treeHeight.Data = root.Height; // must recalculate height because we can't know wether the manipulated branch was the deepest branch
+        gpModel.Size = gpModel.Size - oldChildSize + newChildSize;
+        gpModel.Height = gpModel.FunctionTree.GetHeight(); // must recalculate height because we can't know wether the manipulated branch was the deepest branch
         // check if whole tree is ok
-        Debug.Assert(gardener.IsValidTree(root));
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
         // return a composite operation that initializes all created sub-trees
-        return gardener.CreateInitializationOperation(uninitializedBranches, scope);
+        return TreeGardener.CreateInitializationOperation(uninitializedBranches, scope);
       }
     }
-  
 
     private IFunctionTree ChangeTerminalType(IFunctionTree parent, IFunctionTree child, int childIndex, TreeGardener gardener, MersenneTwister random) {
@@ -133,6 +115,6 @@
         allowedTerminals = new List<IFunction>();
         var allAllowedChildren = gardener.GetAllowedSubFunctions(parent.Function, childIndex);
-        foreach(IFunction c in allAllowedChildren) {
-          if(gardener.IsTerminal(c)) allowedTerminals.Add(c);
+        foreach (IFunction c in allAllowedChildren) {
+          if (TreeGardener.IsTerminal(c)) allowedTerminals.Add(c);
         }
       }
@@ -159,5 +141,5 @@
       if (actualArity > maxArity)
         actualArity = maxArity;
-      if(actualArity < minArity)
+      if (actualArity < minArity)
         actualArity = minArity;
       // create a list that holds old sub-trees that we can reuse in the new tree
@@ -181,5 +163,5 @@
           // no existing matching tree found => create a new tree of minimal size
           IFunctionTree freshTree = gardener.CreateRandomTree(allowedSubFunctions, 1, 1);
-          freshSubTrees.AddRange(gardener.GetAllSubTrees(freshTree));
+          freshSubTrees.AddRange(TreeGardener.GetAllSubTrees(freshTree));
           newTree.InsertSubTree(i, freshTree);
         }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/CutOutNodeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/CutOutNodeManipulation.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/CutOutNodeManipulation.cs	(revision 2210)
@@ -28,7 +28,8 @@
 using System;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
-  public class CutOutNodeManipulation : OperatorBase {
+  public class CutOutNodeManipulation : GPManipulatorBase {
     public override string Description {
       get {
@@ -49,48 +50,29 @@
     public CutOutNodeManipulation()
       : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
     }
 
 
-    public override IOperation Apply(IScope scope) {
-      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
-      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
-      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
+    internal override IOperation Manipulate(MersenneTwister random, IGeneticProgrammingModel gpModel, FunctionLibrary library, int maxTreeSize, int maxTreeHeight, IScope scope) {
       TreeGardener gardener = new TreeGardener(random, library);
-      IFunctionTree parent = gardener.GetRandomParentNode(root);
+      IFunctionTree parent = gardener.GetRandomParentNode(gpModel.FunctionTree);
       // parent == null means we should cut out the root node
       // => return a random sub-tree of the root
       if (parent == null) {
         // when there are sub-trees then replace the old tree with a random sub-tree
-        if (root.SubTrees.Count > 0) {
-          root = root.SubTrees[random.Next(root.SubTrees.Count)];
-          GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-          GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
-          // update the variable
-          scope.GetVariable(scope.TranslateName("FunctionTree")).Value = root;
-          Debug.Assert(gardener.IsValidTree(root));
+        if (gpModel.FunctionTree.SubTrees.Count > 0) {
+          gpModel.FunctionTree = gpModel.FunctionTree.SubTrees[random.Next(gpModel.FunctionTree.SubTrees.Count)];
+          Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
           // we reused a sub-tree so we don't have to schedule initialization operations
           return null;
         } else {
           // we want to cut the root node and there are no sub-trees => create a new random terminal
-          IFunctionTree newTree;
-          newTree = gardener.CreateRandomTree(gardener.Terminals, 1, 1);
-          GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size;
-          GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height;
-          // update the variable
-          scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree;
-          Debug.Assert(gardener.IsValidTree(newTree));
+          gpModel.FunctionTree = gardener.CreateRandomTree(gardener.Terminals, 1, 1);
+          Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
+
           // schedule an operation to initialize the whole tree
-          return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTree), scope);
+          return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(gpModel.FunctionTree), scope);
         }
       }
+
       // select a child to cut away
       int childIndex = random.Next(parent.SubTrees.Count);
@@ -101,11 +83,11 @@
       if (possibleChilds.Length > 0) {
         // replace child with a random child of that child
-        IFunctionTree selectedChild = possibleChilds[random.Next(possibleChilds.Length)];        
+        IFunctionTree selectedChild = possibleChilds[random.Next(possibleChilds.Length)];
         parent.RemoveSubTree(childIndex);
         parent.InsertSubTree(childIndex, selectedChild);
-        Debug.Assert(gardener.IsValidTree(root));
-        // update the size and height of our tree
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
+        // recalculate the size and height of our tree
+        gpModel.Size = gpModel.FunctionTree.GetSize();
+        gpModel.Height = gpModel.FunctionTree.GetHeight();
         // don't need to schedule initialization operations
         return null;
@@ -113,17 +95,18 @@
         // can't reuse an existing branch => create a new tree
         // determine the level of the parent
-        int parentLevel = gardener.GetBranchLevel(root, parent);
+        int parentLevel = gardener.GetBranchLevel(gpModel.FunctionTree, parent);
         // first remove the old child (first step essential!)
         parent.RemoveSubTree(childIndex);
         // then determine the number of nodes left over after the child has been removed!
-        int remainingNodes = root.Size;
+        int remainingNodes = gpModel.FunctionTree.GetSize();
         allowedFunctions = gardener.GetAllowedSubFunctions(parent.Function, childIndex);
         IFunctionTree newFunctionTree = gardener.CreateRandomTree(allowedFunctions, maxTreeSize - remainingNodes, maxTreeHeight - parentLevel);
         parent.InsertSubTree(childIndex, newFunctionTree);
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
-        Debug.Assert(gardener.IsValidTree(root));
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
+        // recalculate size and height
+        gpModel.Size = gpModel.FunctionTree.GetSize();
+        gpModel.Height = gpModel.FunctionTree.GetHeight();
         // schedule an initialization operation for the new function-tree
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newFunctionTree), scope);
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newFunctionTree), scope);
       }
     }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs	(revision 2210)
@@ -27,7 +27,8 @@
 using HeuristicLab.Random;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
-  public class DeleteSubTreeManipulation : OperatorBase {
+  public class DeleteSubTreeManipulation : GPManipulatorBase {
     public override string Description {
       get {
@@ -39,39 +40,24 @@
     public DeleteSubTreeManipulation()
       : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
     }
 
-
-    public override IOperation Apply(IScope scope) {
-      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
-      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
+    internal override IOperation Manipulate(MersenneTwister random, IGeneticProgrammingModel gpModel, FunctionLibrary library, int maxTreeSize, int maxTreeHeight, IScope scope) {
       TreeGardener gardener = new TreeGardener(random, library);
-      IFunctionTree parent = gardener.GetRandomParentNode(root);
+      IFunctionTree parent = gardener.GetRandomParentNode(gpModel.FunctionTree);
 
       // parent==null means the whole tree should be deleted.
       // => return a new minimal random tree
-      if(parent == null) {
+      if (parent == null) {
         IFunctionTree newTree = gardener.CreateBalancedRandomTree(1, 1);
         // check if the tree is ok
         Debug.Assert(gardener.IsValidTree(newTree));
-        // update sizes to match the new tree
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height;
-        scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree;
-
+        gpModel.FunctionTree = newTree;
         // schedule an operation to initialize the newly created operator
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTree), scope);
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newTree), scope);
       }
 
       // select a branch to prune
       int childIndex = random.Next(parent.SubTrees.Count);
-      if(parent.SubTrees.Count > parent.Function.MinArity) {
+      if (parent.SubTrees.Count > parent.Function.MinArity) {
         parent.RemoveSubTree(childIndex);
         // actually since the next sub-trees are shifted in the place of the removed branch
@@ -81,7 +67,8 @@
         // and find the first one that doesn't fit. At this position we insert a new randomly initialized subtree of matching type (gkronber 25.12.07)
 
-        Debug.Assert(gardener.IsValidTree(root));
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
+        // recalculate size and height
+        gpModel.Size = gpModel.FunctionTree.GetSize();
+        gpModel.Height = gpModel.FunctionTree.GetHeight();
         // root hasn't changed so don't need to update 'FunctionTree' variable
         return null;
@@ -92,10 +79,10 @@
         IFunctionTree newFunctionTree = gardener.CreateRandomTree(allowedFunctions, 1, 1);
         parent.InsertSubTree(childIndex, newFunctionTree);
-        Debug.Assert(gardener.IsValidTree(root));
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
-        // again the root hasn't changed so we don't need to update the 'FunctionTree' variable
-        // but we have to return an initialization operation for the newly created tree
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newFunctionTree), scope);
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
+        // recalculate size and height
+        gpModel.Size = gpModel.FunctionTree.GetSize();
+        gpModel.Height = gpModel.FunctionTree.GetHeight();
+        // return an initialization operation for the newly created tree
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newFunctionTree), scope);
       }
     }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/FullTreeShaker.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/FullTreeShaker.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/FullTreeShaker.cs	(revision 2210)
@@ -29,4 +29,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Selection;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -39,43 +40,34 @@
       : base() {
       AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "Function library that defines function mutations", typeof(FunctionLibrary), VariableKind.In));
       AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IGeneticProgrammingModel), VariableKind.In | VariableKind.Out));
     }
 
     public override IOperation Apply(IScope scope) {
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
+      FunctionLibrary library = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, false);
       MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true);
 
-      // enqueue all mutation operations as parallel operations
+      // save all existing sub-scopes in a backup scope
+      Scope backupScope = new Scope("backup");
+      foreach (Scope subScope in scope.SubScopes) {
+        backupScope.AddSubScope(subScope);
+      }
+
+      // create a scope for all shaking operations
+      Scope tempScope = new Scope("Temp. manipulation scope");
+      scope.AddSubScope(tempScope); // scope containing a subscope for each manipulation
+      scope.AddSubScope(backupScope); // scope containing the old subscopes
+
+      // create a composite operation for all shaking operations
       CompositeOperation next = new CompositeOperation();
       next.ExecuteInParallel = false;
 
-      Scope tempScope = new Scope("Temp. manipulation scope");
-
-      TreeGardener gardener = new TreeGardener(mt, library);
-      var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator!= null);
-      foreach(IFunctionTree subTree in parametricBranches) {
-        IOperator mutation = subTree.Manipulator;
-
-        // store all local variables into a temporary scope
-        Scope mutationScope = new Scope();
-        foreach(IVariable variable in subTree.LocalVariables) {
-          mutationScope.AddVariable(variable);
-        }
-
-        tempScope.AddSubScope(mutationScope);
-        next.AddOperation(new AtomicOperation(mutation, mutationScope));
+      // enqueue all shaking operations
+      foreach (IFunctionTree subTree in TreeGardener.GetAllSubTrees(gpModel.FunctionTree).Where(x=>x.HasLocalParameters)) {
+        IOperation shakingOperation = subTree.CreateShakingOperation(tempScope);
+        next.AddOperation(shakingOperation);
       }
-
-      // save all existing sub-scopes in a backup scope
-      Scope backupScope = new Scope("backup");
-      foreach(Scope subScope in scope.SubScopes) {
-        backupScope.AddSubScope(subScope);
-      }
-
-      scope.AddSubScope(tempScope); // scope containing a subscope for each manipulation
-      scope.AddSubScope(backupScope); // scope containing the old subscopes
 
       // schedule a reducer operation to delete all temporary scopes and restore
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/GPManipulatorBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/GPManipulatorBase.cs	(revision 2210)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/GPManipulatorBase.cs	(revision 2210)
@@ -0,0 +1,58 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Operators;
+using HeuristicLab.Random;
+using HeuristicLab.Data;
+using HeuristicLab.Constraints;
+using System.Diagnostics;
+using HeuristicLab.Evolutionary;
+using HeuristicLab.GP.Interfaces;
+
+namespace HeuristicLab.GP {
+  public abstract class GPManipulatorBase : OperatorBase {
+    public GPManipulatorBase()
+      : base() {
+      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to crossover", typeof(IGeneticProgrammingModel), VariableKind.In | VariableKind.New));
+    }
+
+    internal abstract IOperation Manipulate(MersenneTwister random, IGeneticProgrammingModel gpModel, FunctionLibrary library, int maxSize, int maxHeight, IScope scope);
+
+    public override IOperation Apply(IScope scope) {
+      FunctionLibrary funLibrary = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, false);
+      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
+      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
+      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
+
+      return Manipulate(random, gpModel, funLibrary, maxTreeSize, maxTreeHeight, scope);
+    }
+  }
+}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/OnePointShaker.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/OnePointShaker.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/OnePointShaker.cs	(revision 2210)
@@ -29,4 +29,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Selection;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -38,32 +39,21 @@
     public OnePointShaker()
       : base() {
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines mutation operations for operators", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "Function library that defines mutation operations for functions", typeof(FunctionLibrary), VariableKind.In));
       AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
       AddVariableInfo(new VariableInfo("ShakingFactor", "Factor that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IGeneticProgrammingModel), VariableKind.In | VariableKind.Out));
     }
 
     public override IOperation Apply(IScope scope) {
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
+      FunctionLibrary library = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
+      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, false);
       MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true);
-      TreeGardener gardener = new TreeGardener(mt, library);
 
-      // get all nodes for which a manipulation is defined
-      var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator != null);
+      // get all nodes with local parameters
+      var parametricBranches = TreeGardener.GetAllSubTrees(gpModel.FunctionTree).Where(branch => branch.HasLocalParameters);
+      if (parametricBranches.Count() == 0) return null; // don't manipulate anything if there are no nodes with a manipulation operator
+      IFunctionTree selectedBranch = parametricBranches.ElementAt(mt.Next(parametricBranches.Count()));
 
-      if(parametricBranches.Count() == 0) return null; // don't manipulate anything if there are no nodes with a manipulation operator
-
-      IFunctionTree selectedBranch = parametricBranches.ElementAt(mt.Next(parametricBranches.Count()));
-      IOperator mutation = selectedBranch.Manipulator;
-      CompositeOperation next = new CompositeOperation();
-
-      // store all local variables into a temporary scope
-      Scope tempScope = new Scope("Temp. manipulation scope");
-      foreach(IVariable variable in selectedBranch.LocalVariables) {
-        tempScope.AddVariable(variable);
-      }
-
-      // save the exising sub-scops in a backup scope
+      // save the exising sub-scopes in a backup scope
       Scope backupScope = new Scope("backup");
       foreach (Scope subScope in scope.SubScopes) {
@@ -71,10 +61,15 @@
       }
 
+      // create a scope for all shaking operations
+      Scope tempScope = new Scope("Temp. manipulation scope");
+      
       // add the new sub-scopes
       scope.AddSubScope(tempScope);
       scope.AddSubScope(backupScope);
 
+      CompositeOperation next = new CompositeOperation();
+      next.ExecuteInParallel = false;
       // the next operation should first manipulate and then restore the sub-scopes from the backup scope
-      next.AddOperation(new AtomicOperation(mutation, tempScope));
+      next.AddOperation(selectedBranch.CreateShakingOperation(tempScope));
       next.AddOperation(new AtomicOperation(new RightReducer(), scope));
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/SubstituteSubTreeManipulation.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/SubstituteSubTreeManipulation.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/SubstituteSubTreeManipulation.cs	(revision 2210)
@@ -28,7 +28,8 @@
 using HeuristicLab.Random;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
-  public class SubstituteSubTreeManipulation : OperatorBase {
+  public class SubstituteSubTreeManipulation : GPManipulatorBase {
 
     public override string Description {
@@ -38,24 +39,10 @@
     public SubstituteSubTreeManipulation()
       : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to manipulate", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
     }
 
-    public override IOperation Apply(IScope scope) {
-      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
-      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
-      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
-      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
-      int treeSize = GetVariableValue<IntData>("TreeSize", scope, true).Data;
-      int treeHeight = GetVariableValue<IntData>("TreeHeight", scope, true).Data;
+    internal override IOperation Manipulate(MersenneTwister random, IGeneticProgrammingModel gpModel, FunctionLibrary library, int maxTreeSize, int maxTreeHeight, IScope scope) {
       TreeGardener gardener = new TreeGardener(random, library);
-      IFunctionTree parent = gardener.GetRandomParentNode(root);
-      if(parent == null) {
+      IFunctionTree parent = gardener.GetRandomParentNode(gpModel.FunctionTree);
+      if (parent == null) {
         // parent == null means we should subsitute the whole tree
         // => create a new random tree
@@ -63,11 +50,7 @@
         Debug.Assert(gardener.IsValidTree(newTree));
 
-        // update the variables in the scope with the new values
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height;
-        scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree;
-        
+        gpModel.FunctionTree = newTree;
         // return a CompositeOperation that randomly initializes the new tree
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTree), scope);
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newTree), scope);
       } else {
         // determine a random child of the parent to be replaced
@@ -75,5 +58,5 @@
         // get the list of allowed functions for the new sub-tree
         ICollection<IFunction> allowedFunctions = gardener.GetAllowedSubFunctions(parent.Function, childIndex);
-        if(allowedFunctions.Count == 0) {
+        if (allowedFunctions.Count == 0) {
           // don't change anything
           // this shouldn't happen
@@ -83,7 +66,7 @@
         // calculate the maximum size and height of the new sub-tree based on the location where
         // it will be inserted
-        int parentLevel = gardener.GetBranchLevel(root, parent);
+        int parentLevel = gardener.GetBranchLevel(gpModel.FunctionTree, parent);
         int maxSubTreeHeight = maxTreeHeight - parentLevel;
-        int maxSubTreeSize = maxTreeSize - (treeSize - parent.SubTrees[childIndex].Size);
+        int maxSubTreeSize = maxTreeSize - (gpModel.Size - parent.SubTrees[childIndex].GetSize());
 
         // create a random function tree
@@ -92,11 +75,11 @@
         parent.InsertSubTree(childIndex, newTree);
 
-        Debug.Assert(gardener.IsValidTree(root));
+        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
         // update the values of treeSize and treeHeight
-        GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size;
-        GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height;
+        gpModel.Size = gpModel.FunctionTree.GetSize();
+        gpModel.Height = gpModel.FunctionTree.GetHeight();
         // the root hasn't changed so we don't need to update 
         // return a CompositeOperation that randomly initializes all nodes of the new subtree
-        return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTree), scope);
+        return TreeGardener.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newTree), scope);
       }
     }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/ProbabilisticTreeCreator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/ProbabilisticTreeCreator.cs	(revision 2202)
+++ 	(revision )
@@ -1,83 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System.Linq;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Operators;
-using System;
-using HeuristicLab.Random;
-using System.Diagnostics;
-
-namespace HeuristicLab.GP {
-  public class ProbabilisticTreeCreator : OperatorBase {
-    private int MAX_TRIES { get { return 100; } }
-
-    public override string Description {
-      get { return @"Generates a new random operator tree."; }
-    }
-
-    public ProbabilisticTreeCreator()
-      : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MinTreeSize", "The minimal allowed size of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IFunctionTree), VariableKind.New | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
-    }
-
-    public override IOperation Apply(IScope scope) {
-      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
-      FunctionLibrary opLibrary = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      int minTreeSize = GetVariableValue<IntData>("MinTreeSize", scope, true).Data;
-      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
-      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
-
-      TreeGardener gardener = new TreeGardener(random, opLibrary);
-
-      int treeSize = random.Next(minTreeSize, maxTreeSize + 1);
-
-      IFunctionTree root;
-      int actualTreeSize;
-      int actualTreeHeight;
-      int tries = 0;
-      do {
-        root = gardener.PTC2(random, treeSize, maxTreeHeight);
-        actualTreeSize = root.Size;
-        actualTreeHeight = root.Height;
-        if (tries++ >= MAX_TRIES) {
-          // try a different size
-          treeSize = random.Next(minTreeSize, maxTreeSize + 1);
-          tries = 0;
-        }
-      } while (actualTreeSize > maxTreeSize || actualTreeHeight > maxTreeHeight);
-
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), root));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(actualTreeSize)));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(actualTreeHeight)));
-
-      return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(root), scope);
-    }
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/RampedTreeCreator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/RampedTreeCreator.cs	(revision 2202)
+++ 	(revision )
@@ -1,77 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System.Linq;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Operators;
-using System;
-using HeuristicLab.Random;
-using System.Diagnostics;
-
-namespace HeuristicLab.GP {
-  public class RampedTreeCreator : OperatorBase {
-    public override string Description {
-      get { return @"Generates a new random operator tree."; }
-    }
-
-    public RampedTreeCreator()
-      : base() {
-      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MinTreeHeight", "The minimal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IFunctionTree), VariableKind.New | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
-    }
-
-    public override IOperation Apply(IScope scope) {
-      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
-      FunctionLibrary opLibrary = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
-      int minTreeHeight = GetVariableValue<IntData>("MinTreeHeight", scope, true).Data;
-      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
-      double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data;
-
-      TreeGardener gardener = new TreeGardener(random, opLibrary);
-
-      int treeHeight = random.Next(minTreeHeight, maxTreeHeight + 1);
-      IFunctionTree root;
-      if(random.NextDouble() <= balancedTreesRate) {
-        root = gardener.CreateBalancedRandomTree(Int32.MaxValue, treeHeight);
-      } else {
-        root = gardener.CreateUnbalancedRandomTree(Int32.MaxValue, treeHeight);
-      }
-
-      int actualTreeSize = root.Size;
-      int actualTreeHeight = root.Height;
-
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), root));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(actualTreeSize)));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(actualTreeHeight)));
-
-      Debug.Assert(gardener.IsValidTree(root) && actualTreeHeight <= maxTreeHeight);
-
-      return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(root), scope);
-    }
-  }
-}
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/GPCrossoverBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/GPCrossoverBase.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/GPCrossoverBase.cs	(revision 2210)
@@ -31,4 +31,5 @@
 using System.Diagnostics;
 using HeuristicLab.Evolutionary;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -36,8 +37,6 @@
     public GPCrossoverBase()
       : base() {
-      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In | VariableKind.New));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New));
+      AddVariableInfo(new VariableInfo("FunctionLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
+      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to crossover", typeof(IGeneticProgrammingModel), VariableKind.In | VariableKind.New));
     }
 
@@ -45,5 +44,5 @@
 
     protected override void Cross(IScope scope, IRandom random) {
-      FunctionLibrary opLibrary = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
+      FunctionLibrary opLibrary = GetVariableValue<FunctionLibrary>("FunctionLibrary", scope, true);
       TreeGardener gardener = new TreeGardener(random, opLibrary);
 
@@ -51,19 +50,17 @@
         throw new InvalidOperationException("Number of parents must be exactly two.");
 
-      IFunctionTree parent0 = GetVariableValue<IFunctionTree>("FunctionTree", scope.SubScopes[0], false);
-      IFunctionTree parent1 = GetVariableValue<IFunctionTree>("FunctionTree", scope.SubScopes[1], false);
+      IGeneticProgrammingModel parent0 = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope.SubScopes[0], false);
+      IGeneticProgrammingModel parent1 = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope.SubScopes[1], false);
 
       // randomly swap parents to remove a possible bias from selection (e.g. when using gender-specific selection)
       if (random.NextDouble() < 0.5) {
-        IFunctionTree tmp = parent0;
+        IGeneticProgrammingModel tmp = parent0;
         parent0 = parent1;
         parent1 = tmp;
       }
 
-      IFunctionTree child = Cross(scope, gardener, random, parent0, parent1);
+      IFunctionTree child = Cross(scope, gardener, random, parent0.FunctionTree, parent1.FunctionTree);
       Debug.Assert(gardener.IsValidTree(child));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), child));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(child.Size)));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(child.Height)));
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), new GeneticProgrammingModel(child)));
     }
   }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/LangdonHomologousCrossOver.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/LangdonHomologousCrossOver.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/LangdonHomologousCrossOver.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/OnePointCrossOver.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/OnePointCrossOver.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/OnePointCrossOver.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -51,5 +52,5 @@
     internal override IFunctionTree Cross(TreeGardener gardener, IRandom random, IFunctionTree tree0, IFunctionTree tree1, int maxTreeSize, int maxTreeHeight) {
       List<CrossoverPoint> allowedCrossOverPoints = new List<CrossoverPoint>();
-      GetCrossOverPoints(gardener, tree0, tree1, maxTreeSize - tree0.Size, allowedCrossOverPoints);
+      GetCrossOverPoints(gardener, tree0, tree1, maxTreeSize - tree0.GetSize(), allowedCrossOverPoints);
       if (allowedCrossOverPoints.Count > 0) {
         CrossoverPoint crossOverPoint = allowedCrossOverPoints[random.Next(allowedCrossOverPoints.Count)];
@@ -68,5 +69,5 @@
         // if the current branch can be attached as a sub-tree to branch0
         if (gardener.GetAllowedSubFunctions(branch0.Function, i).Contains(branch1.SubTrees[i].Function) &&
-           branch1.SubTrees[i].Size - branch0.SubTrees[i].Size <= maxNewNodes) {
+           branch1.SubTrees[i].GetSize() - branch0.SubTrees[i].GetSize() <= maxNewNodes) {
           CrossoverPoint p = new CrossoverPoint();
           p.childIndex = i;
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeConstrictedGPCrossoverBase.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeConstrictedGPCrossoverBase.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeConstrictedGPCrossoverBase.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -58,15 +59,9 @@
           newTree = Cross(gardener, random, (IFunctionTree)tree1.Clone(), (IFunctionTree)tree0.Clone(), maxTreeSize, maxTreeHeight);
         } else newTree = tree0;
-      } while (newTree.Size > maxTreeSize || newTree.Height > maxTreeHeight);
+      } while (newTree.GetSize() > maxTreeSize || newTree.GetHeight() > maxTreeHeight);
       return newTree;
     }
 
     internal abstract IFunctionTree Cross(TreeGardener gardener, IRandom random, IFunctionTree tree0, IFunctionTree tree1, int maxTreeSize, int maxTreeHeight);
-
-    //private IFunctionTree TakeNextParent(IScope scope) {
-    //  IFunctionTree parent = GetVariableValue<IFunctionTree>("FunctionTree", scope.SubScopes[0], false);
-    //  scope.RemoveSubScope(scope.SubScopes[0]);
-    //  return parent;
-    //}
   }
 }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeFairCrossOver.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeFairCrossOver.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/SizeFairCrossOver.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -69,6 +70,6 @@
     private IFunctionTree GetReplacementBranch(MersenneTwister random, TreeGardener gardener, IFunctionTree intoTree, IFunctionTree parent, int replacedBranchIndex, IFunctionTree fromTree, int maxTreeSize, int maxTreeHeight) {
       IList<IFunction> allowedFunctions = new List<IFunction>(gardener.GetAllowedSubFunctions(parent.Function, replacedBranchIndex));
-      int removedBranchSize = parent.SubTrees[replacedBranchIndex].Size;
-      int maxBranchSize = maxTreeSize - (intoTree.Size - removedBranchSize);
+      int removedBranchSize = parent.SubTrees[replacedBranchIndex].GetSize();
+      int maxBranchSize = maxTreeSize - (intoTree.GetSize() - removedBranchSize);
       int maxBranchHeight = maxTreeHeight - gardener.GetBranchLevel(intoTree, parent);  // returns 1 if intoTree==parent and 2 if parent is a child of intoTree
       List<int> replacedTrail = GetTrail(intoTree, parent);
@@ -84,5 +85,5 @@
         double pEqualLength = equalLengthBranches.Count > 0 ? 1.0 / removedBranchSize : 0.0;
         double pLonger;
-        if (parent.Size == maxTreeSize) {
+        if (parent.GetSize() == maxTreeSize) {
           pLonger = 0.0;
         } else {
@@ -112,6 +113,6 @@
     private void FindPossibleBranches(IFunctionTree tree, IList<IFunction> allowedFunctions, int maxBranchSize, int maxBranchHeight, int removedBranchSize,
       List<CrossoverPoint> shorterBranches, List<CrossoverPoint> equalLengthBranches, List<CrossoverPoint> longerBranches, List<int> trail) {
-      int treeSize = tree.Size;
-      if (allowedFunctions.Contains(tree.Function) && treeSize <= maxBranchSize && tree.Height <= maxBranchHeight) {
+      int treeSize = tree.GetSize();
+      if (allowedFunctions.Contains(tree.Function) && treeSize <= maxBranchSize && tree.GetHeight() <= maxBranchHeight) {
         CrossoverPoint p = new CrossoverPoint();
         p.branchSize = treeSize;
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/StandardCrossOver.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/StandardCrossOver.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/StandardCrossOver.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -57,9 +58,9 @@
 
         // calculate the max size and height that the inserted branch can have 
-        int maxInsertedBranchSize = maxTreeSize - (tree0.Size - parent0.SubTrees[replacedChildIndex].Size);
+        int maxInsertedBranchSize = maxTreeSize - (tree0.GetSize() - parent0.SubTrees[replacedChildIndex].GetSize());
         int maxInsertedBranchHeight = maxTreeHeight - gardener.GetBranchLevel(tree0, parent0); // branchlevel is 1 if tree0==parent0
 
         IList<IFunction> allowedFunctions = new List<IFunction>(gardener.GetAllowedSubFunctions(parent0.Function, replacedChildIndex));
-        allowedCrossoverPoints = GetPossibleCrossoverPoints(gardener, tree1, maxInsertedBranchSize, maxInsertedBranchHeight, allowedFunctions);
+        allowedCrossoverPoints = GetPossibleCrossoverPoints(tree1, maxInsertedBranchSize, maxInsertedBranchHeight, allowedFunctions);
       } while (allowedCrossoverPoints.Count == 0 && tries++ < MaxRecombinationTries);
 
@@ -74,8 +75,8 @@
     }
 
-    private List<IFunctionTree> GetPossibleCrossoverPoints(TreeGardener gardener, IFunctionTree tree, int maxInsertedBranchSize, int maxInsertedBranchHeight, IList<IFunction> allowedFunctions) {
+    private List<IFunctionTree> GetPossibleCrossoverPoints(IFunctionTree tree, int maxInsertedBranchSize, int maxInsertedBranchHeight, IList<IFunction> allowedFunctions) {
       List<IFunctionTree> crossoverPoints = new List<IFunctionTree>();
-      foreach (IFunctionTree possiblePoint in gardener.GetAllSubTrees(tree)) {
-        if (allowedFunctions.Contains(possiblePoint.Function) && possiblePoint.Size <= maxInsertedBranchSize && possiblePoint.Height <= maxInsertedBranchHeight)
+      foreach (IFunctionTree possiblePoint in TreeGardener.GetAllSubTrees(tree)) {
+        if (allowedFunctions.Contains(possiblePoint.Function) && possiblePoint.GetSize() <= maxInsertedBranchSize && possiblePoint.GetHeight() <= maxInsertedBranchHeight)
           crossoverPoints.Add(possiblePoint);
       }
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/UniformCrossover.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/UniformCrossover.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Recombination/UniformCrossover.cs	(revision 2210)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using System.Diagnostics;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
Index: branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/TreeGardener.cs	(revision 2210)
@@ -32,4 +32,5 @@
 using System.Collections;
 using HeuristicLab.Selection;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.GP {
@@ -96,11 +97,11 @@
     }
 
-    internal IFunctionTree PTC2(IRandom random, int size, int maxDepth) {
-      return PTC2(random, GetRandomRoot(size, maxDepth), size, maxDepth);
-    }
-
-    internal IFunctionTree PTC2(IRandom random, IFunction rootF, int size, int maxDepth) {
-      IFunctionTree root = rootF.GetTreeNode();
-      if(size <= 1 || maxDepth <= 1) return root;
+    public IFunctionTree PTC2(int size, int maxDepth) {
+      return PTC2(GetRandomRoot(size, maxDepth), size, maxDepth);
+    }
+
+    private IFunctionTree PTC2(IFunction rootFunction, int size, int maxDepth) {
+      IFunctionTree root = rootFunction.GetTreeNode();
+      if (size <= 1 || maxDepth <= 1) return root;
       List<object[]> list = new List<object[]>();
       int currentSize = 1;
@@ -108,10 +109,10 @@
       int minArity = root.Function.MinArity;
       int maxArity = root.Function.MaxArity;
-      if(maxArity >= size) {
+      if (maxArity >= size) {
         maxArity = size;
       }
       int actualArity = random.Next(minArity, maxArity + 1);
       totalListMinSize += root.Function.MinTreeSize - 1;
-      for(int i = 0; i < actualArity; i++) {
+      for (int i = 0; i < actualArity; i++) {
         // insert a dummy sub-tree and add the pending extension to the list
         root.AddSubTree(null);
@@ -119,5 +120,5 @@
       }
 
-      while(list.Count > 0 && totalListMinSize + currentSize < size) {
+      while (list.Count > 0 && totalListMinSize + currentSize < size) {
         int randomIndex = random.Next(list.Count);
         object[] nextExtension = list[randomIndex];
@@ -126,13 +127,13 @@
         int a = (int)nextExtension[1];
         int d = (int)nextExtension[2];
-        if(d == maxDepth) {
+        if (d == maxDepth) {
           parent.RemoveSubTree(a);
           IFunctionTree branch = CreateRandomTree(GetAllowedSubFunctions(parent.Function, a), 1, 1);
           parent.InsertSubTree(a, branch); // insert a smallest possible tree
-          currentSize += branch.Size;
-          totalListMinSize -= branch.Size;
+          currentSize += branch.GetSize();
+          totalListMinSize -= branch.GetSize();
         } else {
-          IFunction selectedFunction = RandomSelect(GetAllowedSubFunctions(parent.Function, a).Where(
-            f => !IsTerminal(f) && f.MinTreeHeight + (d - 1) <= maxDepth).ToArray());
+          IFunction selectedFunction = TreeGardener.RandomSelect(random, GetAllowedSubFunctions(parent.Function, a).Where(
+            f => !TreeGardener.IsTerminal(f) && f.MinTreeHeight + (d - 1) <= maxDepth).ToArray());
           IFunctionTree newTree = selectedFunction.GetTreeNode();
           parent.RemoveSubTree(a);
@@ -143,9 +144,9 @@
           minArity = selectedFunction.MinArity;
           maxArity = selectedFunction.MaxArity;
-          if(maxArity >= size) {
+          if (maxArity >= size) {
             maxArity = size;
           }
           actualArity = random.Next(minArity, maxArity + 1);
-          for(int i = 0; i < actualArity; i++) {
+          for (int i = 0; i < actualArity; i++) {
             // insert a dummy sub-tree and add the pending extension to the list
             newTree.AddSubTree(null);
@@ -155,5 +156,5 @@
         }
       }
-      while(list.Count > 0) {
+      while (list.Count > 0) {
         int randomIndex = random.Next(list.Count);
         object[] nextExtension = list[randomIndex];
@@ -168,5 +169,5 @@
       return root;
     }
-
+ 
     /// <summary>
     /// selects a random function from allowedFunctions and creates a random (unbalanced) tree with maximal size and height.
@@ -197,28 +198,21 @@
       // build the tree 
       IFunctionTree root;
-      root = PTC2(random, selectedFunction, maxTreeSize, maxTreeHeight);
+      root = PTC2(selectedFunction, maxTreeSize, maxTreeHeight);
       return root;
     }
 
-    internal CompositeOperation CreateInitializationOperation(ICollection<IFunctionTree> trees, IScope scope) {
-      // needed for the parameter shaking operation
+    internal static CompositeOperation CreateInitializationOperation(ICollection<IFunctionTree> trees, IScope scope) {
+      // create a backup of sub scopes to restore after initialization
+      Scope backupScope = new Scope("backup");
+      foreach (Scope subScope in scope.SubScopes) {
+        backupScope.AddSubScope(subScope);
+      }
+
       CompositeOperation initializationOperation = new CompositeOperation();
       Scope tempScope = new Scope("Temp. initialization scope");
 
-      var parametricTrees = trees.Where(t => t.Initializer != null);
+      var parametricTrees = trees.Where(t => t.HasLocalParameters);
       foreach(IFunctionTree tree in parametricTrees) {
-        // enqueue an initialization operation for each operator with local variables 
-        IOperator initialization = tree.Initializer;
-        Scope initScope = new Scope();
-        // copy the local variables into a temporary scope used for initialization
-        foreach(IVariable variable in tree.LocalVariables) {
-          initScope.AddVariable(variable);
-        }
-        tempScope.AddSubScope(initScope);
-        initializationOperation.AddOperation(new AtomicOperation(initialization, initScope));
-      }
-      Scope backupScope = new Scope("backup");
-      foreach(Scope subScope in scope.SubScopes) {
-        backupScope.AddSubScope(subScope);
+        initializationOperation.AddOperation(tree.CreateInitOperation(tempScope));
       }
       scope.AddSubScope(tempScope);
@@ -246,5 +240,5 @@
     }
 
-    internal ICollection<IFunctionTree> GetAllSubTrees(IFunctionTree root) {
+    internal static ICollection<IFunctionTree> GetAllSubTrees(IFunctionTree root) {
       List<IFunctionTree> allTrees = new List<IFunctionTree>();
       TreeForEach(root, t => { allTrees.Add(t); });
@@ -375,5 +369,5 @@
       return parents;
     }
-    internal bool IsTerminal(IFunction f) {
+    internal static bool IsTerminal(IFunction f) {
       return f.MinArity == 0 && f.MaxArity == 0;
     }
@@ -388,5 +382,5 @@
 
     #region private utility methods
-    private IFunction GetRandomRoot(int maxTreeSize, int maxTreeHeight) {
+    public IFunction GetRandomRoot(int maxTreeSize, int maxTreeHeight) {
       if(maxTreeHeight == 1 || maxTreeSize == 1) {
         IFunction selectedTerminal = RandomSelect(terminals);
@@ -450,5 +444,5 @@
     }
 
-    private void TreeForEach(IFunctionTree tree, Action<IFunctionTree> action) {
+    private static void TreeForEach(IFunctionTree tree, Action<IFunctionTree> action) {
       action(tree);
       foreach(IFunctionTree subTree in tree.SubTrees) {
@@ -457,8 +451,8 @@
     }
 
-    private void GetBranchesAtLevel(IFunctionTree tree, int level, List<IFunctionTree> result) {
+    private static void GetBranchesAtLevel(IFunctionTree tree, int level, List<IFunctionTree> result) {
       if(level == 1) result.AddRange(tree.SubTrees);
       foreach(IFunctionTree subTree in tree.SubTrees) {
-        if(subTree.Height >= level - 1)
+        if(subTree.GetHeight() >= level - 1)
           GetBranchesAtLevel(subTree, level - 1, result);
       }
@@ -466,9 +460,13 @@
 
     private IFunction RandomSelect(IList<IFunction> functionSet) {
+      return RandomSelect(random, functionSet);
+    }
+
+    public static IFunction RandomSelect(IRandom random, IList<IFunction> functionSet) {
       double[] accumulatedTickets = new double[functionSet.Count];
       double ticketAccumulator = 0;
       int i = 0;
       // precalculate the slot-sizes
-      foreach(IFunction function in functionSet) {
+      foreach (IFunction function in functionSet) {
         ticketAccumulator += function.Tickets;
         accumulatedTickets[i] = ticketAccumulator;
@@ -478,6 +476,6 @@
       double r = random.NextDouble() * ticketAccumulator;
       // find the slot that has been hit
-      for(i = 0; i < accumulatedTickets.Length; i++) {
-        if(r < accumulatedTickets[i]) return functionSet[i];
+      for (i = 0; i < accumulatedTickets.Length; i++) {
+        if (r < accumulatedTickets[i]) return functionSet[i];
       }
       // sanity check
Index: branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLab.LinearRegression-3.2.csproj
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLab.LinearRegression-3.2.csproj	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLab.LinearRegression-3.2.csproj	(revision 2210)
@@ -113,4 +113,8 @@
       <Name>HeuristicLab.Data-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
+      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
+      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
       <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
Index: branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLabLinearRegressionPlugin.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLabLinearRegressionPlugin.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLabLinearRegressionPlugin.cs	(revision 2210)
@@ -32,4 +32,5 @@
   [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
+  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
   [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
   [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
Index: branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs	(revision 2210)
@@ -34,4 +34,5 @@
 using HeuristicLab.GP;
 using HeuristicLab.Random;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.LinearRegression {
@@ -281,5 +282,5 @@
       model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
 
-      model.Data = bestModelScope.GetVariableValue<IFunctionTree>("LinearRegressionModel", false);
+      model.Data = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("LinearRegressionModel", false);
       HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
       model.Dataset = ds;
Index: branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2210)
@@ -28,4 +28,5 @@
 using HeuristicLab.GP;
 using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.GP.Interfaces;
 
 namespace HeuristicLab.LinearRegression {
@@ -38,7 +39,5 @@
       AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
       AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("LinearRegressionModel", "Formula that was calculated by linear regression", typeof(IFunctionTree), VariableKind.Out | VariableKind.New));
-      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
-      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("LinearRegressionModel", "Formula that was calculated by linear regression", typeof(IGeneticProgrammingModel), VariableKind.Out | VariableKind.New));
     }
 
@@ -55,8 +54,6 @@
       double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
       IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList());
-
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), tree));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(tree.Size)));
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(tree.Height)));
+      
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree)));
       return null;
     }
@@ -73,13 +70,13 @@
       GP.StructureIdentification.Variable v;
       for (int i = 0; i < coefficients.Length - 1; i++) {
-        var vNode = new GP.StructureIdentification.Variable().GetTreeNode();
-        vNode.GetLocalVariable(GP.StructureIdentification.Variable.INDEX).Value = new StringData(allowedVariables[i]);
-        vNode.GetLocalVariable(GP.StructureIdentification.Variable.WEIGHT).Value = new DoubleData(coefficients[i]);
-        vNode.GetLocalVariable(GP.StructureIdentification.Variable.OFFSET).Value = new ConstrainedIntData(0);
+        var vNode = (VariableFunctionTree)new GP.StructureIdentification.Variable().GetTreeNode();
+        vNode.VariableName = allowedVariables[i];
+        vNode.Weight = coefficients[i];
+        vNode.SampleOffset = 0;
         nodes.Enqueue(vNode);
       }
-      var cNode = new Constant().GetTreeNode();
+      var cNode = (ConstantFunctionTree)new Constant().GetTreeNode();
 
-      cNode.GetLocalVariable(GP.StructureIdentification.Constant.VALUE).Value = new DoubleData(coefficients[coefficients.Length - 1]);
+      cNode.Value = coefficients[coefficients.Length - 1];
       nodes.Enqueue(cNode);
 
Index: branches/GP-Refactoring-713/sources/HeuristicLab.Random/3.2/NormalDistributedRandom.cs
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.Random/3.2/NormalDistributedRandom.cs	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.Random/3.2/NormalDistributedRandom.cs	(revision 2210)
@@ -55,5 +55,5 @@
     }
     private IRandom uniform;
-    private double[] w = new double[] {
+    private static readonly double[] w = new double[] {
       1.7290404664e-09,
       1.2680928529e-10,
@@ -185,5 +185,5 @@
       1.6030947680e-09
     };
-    private long[] k = new long[] {
+    private static readonly long[] k = new long[] {
       1991057938,
       0,
@@ -315,5 +315,5 @@
       2010539237
    };
-    private double[] f = new double[] {
+    private static readonly double[] f = new double[] {
       1.0000000000e+00,
       9.6359968185e-01,
Index: branches/GP-Refactoring-713/sources/HeuristicLab.sln
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab.sln	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab.sln	(revision 2210)
@@ -235,4 +235,6 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.LinearRegression-3.2", "HeuristicLab.LinearRegression\3.2\HeuristicLab.LinearRegression-3.2.csproj", "{B9A64475-D542-47CF-9688-735F6224F055}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.GP.Interfaces-3.3", "HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj", "{924B6BEA-9A99-40FE-9334-5C01E8D540EC}"
 EndProject
 Global
@@ -3768,4 +3770,33 @@
 		{B9A64475-D542-47CF-9688-735F6224F055}.Visualization Debug|x86.ActiveCfg = Debug|x86
 		{B9A64475-D542-47CF-9688-735F6224F055}.Visualization Debug|x86.Build.0 = Debug|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.CEDMA Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.CEDMA Debug|Any CPU.Build.0 = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.CEDMA Debug|x64.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.CEDMA Debug|x86.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|x64.ActiveCfg = Debug|x64
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|x64.Build.0 = Debug|x64
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|x86.ActiveCfg = Debug|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Debug|x86.Build.0 = Debug|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Modeling Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Modeling Debug|Any CPU.Build.0 = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Modeling Debug|x64.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Modeling Debug|x86.ActiveCfg = Debug|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Modeling Debug|x86.Build.0 = Debug|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|x64.ActiveCfg = Release|x64
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|x64.Build.0 = Release|x64
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|x86.ActiveCfg = Release|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Release|x86.Build.0 = Release|x86
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.v3.2 Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.v3.2 Debug|Any CPU.Build.0 = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.v3.2 Debug|x64.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.v3.2 Debug|x86.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Visualization Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Visualization Debug|Any CPU.Build.0 = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Visualization Debug|x64.ActiveCfg = Debug|Any CPU
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC}.Visualization Debug|x86.ActiveCfg = Debug|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
@@ -3854,4 +3885,5 @@
 		{C75532C4-765B-418E-B09B-46D36B2ABDB1} = {410732DB-725A-4824-896B-C298978343C0}
 		{B9A64475-D542-47CF-9688-735F6224F055} = {410732DB-725A-4824-896B-C298978343C0}
+		{924B6BEA-9A99-40FE-9334-5C01E8D540EC} = {410732DB-725A-4824-896B-C298978343C0}
 		{A9E282EA-180F-4233-B809-AEDF0787545C} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}
 		{BF7D9494-A586-457B-8DF9-ED599F9E6A71} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}
Index: branches/GP-Refactoring-713/sources/HeuristicLab/CopyAssemblies.cmd
===================================================================
--- branches/GP-Refactoring-713/sources/HeuristicLab/CopyAssemblies.cmd	(revision 2202)
+++ branches/GP-Refactoring-713/sources/HeuristicLab/CopyAssemblies.cmd	(revision 2210)
@@ -42,4 +42,5 @@
 copy "%SolutionDir%\HeuristicLab.GP\3.3\%Outdir%\HeuristicLab.GP-3.3.dll" .\plugins
 REM copy "%SolutionDir%\HeuristicLab.GP\3.4\%Outdir%\HeuristicLab.GP-3.4.dll" .\plugins
+copy "%SolutionDir%\HeuristicLab.GP.Interfaces\3.3\%Outdir%\HeuristicLab.GP.Interfaces-3.3.dll" .\plugins
 copy "%SolutionDir%\HeuristicLab.GP.Boolean\3.3\%Outdir%\HeuristicLab.GP.Boolean-3.3.dll" .\plugins
 copy "%SolutionDir%\HeuristicLab.GP.SantaFe\3.3\%Outdir%\HeuristicLab.GP.SantaFe-3.3.dll" .\plugins
