Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
   partial class SymbolicExpressionGrammarEditorView {
     /// <summary> 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs	(revision 8935)
@@ -157,5 +157,5 @@
     #region events
     public event MouseEventHandler SymbolicExpressionTreeNodeClicked;
-    protected void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
+    protected virtual void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
       var clicked = SymbolicExpressionTreeNodeClicked;
       if (clicked != null)
@@ -163,5 +163,5 @@
     }
 
-    protected virtual void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
+    private void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
       VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
       if (visualTreeNode != null) {
@@ -171,5 +171,5 @@
 
     public event MouseEventHandler SymbolicExpressionTreeNodeDoubleClicked;
-    protected void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
+    protected virtual void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
       var doubleClicked = SymbolicExpressionTreeNodeDoubleClicked;
       if (doubleClicked != null)
@@ -184,5 +184,5 @@
 
     public event ItemDragEventHandler SymbolicExpressionTreeNodeDrag;
-    protected void OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) {
+    protected virtual void OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) {
       var dragged = SymbolicExpressionTreeNodeDrag;
       if (dragged != null)
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 8935)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 
@@ -48,10 +49,10 @@
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
-      return calculator.CalculateReplacementValues(tree, Content.Model.Interpreter, Content.ProblemData);
+      return calculator.CalculateReplacementValues(tree, Content.Model.Interpreter, Content.ProblemData).ToDictionary(x => x.Item1, x => x.Item2);
     }
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
       return calculator.CalculateImpactValues(tree, Content.Model.Interpreter, Content.ProblemData,
-                                               Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
+                                              Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit).ToDictionary(x => x.Item1, x => x.Item2); ;
     }
 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿using System.Collections.Generic;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Collections.Generic;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolutionImpactValuesCalculator.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolutionImpactValuesCalculator.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolutionImpactValuesCalculator.cs	(revision 8935)
@@ -1,3 +1,25 @@
-﻿using System.Collections.Generic;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
 using System.Linq;
 using HeuristicLab.Common;
@@ -6,52 +28,52 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
   public class SymbolicDiscriminantFunctionClassificationSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
-    public override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree,
-                                                                                      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
-                                                                                      IDataAnalysisProblemData problemData) {
-      var replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
-        replacementValues[node] = CalculateReplacementValue(node, tree, interpreter, problemData);
-      }
-      return replacementValues;
+    public override IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateReplacementValues(ISymbolicExpressionTree tree,
+                                                                                                       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                       IDataAnalysisProblemData problemData) {
+      return from node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()
+             select new Tuple<ISymbolicExpressionTreeNode, double>(node, CalculateReplacementValue(node, tree, interpreter, problemData));
     }
-    public override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree,
-                                                                                 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
-                                                                                 IDataAnalysisProblemData classificationProblemData,
-                                                                                 double lowerEstimationLimit, double upperEstimationLimit) {
+
+    public override IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateImpactValues(ISymbolicExpressionTree tree,
+                                                                                                  ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                  IDataAnalysisProblemData classificationProblemData,
+                                                                                                  double lowerEstimationLimit, double upperEstimationLimit) {
       var problemData = (IClassificationProblemData)classificationProblemData;
       var dataset = problemData.Dataset;
       var rows = problemData.TrainingIndices;
       string targetVariable = problemData.TargetVariable;
-      Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
-
       var targetClassValues = dataset.GetDoubleValues(targetVariable, rows);
-      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)
-        .LimitToRange(lowerEstimationLimit, upperEstimationLimit)
-        .ToArray();
+      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).LimitToRange(lowerEstimationLimit, upperEstimationLimit).ToArray();
       OnlineCalculatorError errorState;
       double originalGini = NormalizedGiniCalculator.Calculate(targetClassValues, originalOutput, out errorState);
       if (errorState != OnlineCalculatorError.None) originalGini = 0.0;
 
-      foreach (ISymbolicExpressionTreeNode node in nodes) {
-        var parent = node.Parent;
-        var constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode());
-        constantNode.Value = CalculateReplacementValue(node, tree, interpreter, classificationProblemData);
-        ISymbolicExpressionTreeNode replacementNode = constantNode;
-        SwitchNode(parent, node, replacementNode);
-        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)
-          .LimitToRange(lowerEstimationLimit, upperEstimationLimit)
-          .ToArray();
-        double newGini = NormalizedGiniCalculator.Calculate(targetClassValues, newOutput, out errorState);
-        if (errorState != OnlineCalculatorError.None) newGini = 0.0;
+      return from node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix()
+             select new Tuple<ISymbolicExpressionTreeNode, double>(node, CalculateImpact(tree, originalGini, node, interpreter, problemData, lowerEstimationLimit, upperEstimationLimit));
+    }
 
-        // impact = 0 if no change
-        // impact < 0 if new solution is better
-        // impact > 0 if new solution is worse
-        impactValues[node] = originalGini - newGini;
-        SwitchNode(parent, replacementNode, node);
-      }
-      return impactValues;
+    private static double CalculateImpact(ISymbolicExpressionTree tree, double originalQuality, ISymbolicExpressionTreeNode node,
+                                          ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IClassificationProblemData problemData,
+                                          double lowerEstimationLimit, double upperEstimationLimit) {
+      var dataset = problemData.Dataset;
+      var rows = problemData.TrainingIndices.ToList();
+      string targetVariable = problemData.TargetVariable;
+      var targetValues = dataset.GetDoubleValues(targetVariable, rows).ToList();
 
+      var parent = node.Parent;
+      var constantNode = (ConstantTreeNode)new Constant().CreateTreeNode();
+      constantNode.Value = CalculateReplacementValue(node, tree, interpreter, problemData);
+      SwitchNode(parent, node, constantNode);
+      var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)
+                                 .LimitToRange(lowerEstimationLimit, upperEstimationLimit)
+                                 .ToArray();
+      OnlineCalculatorError errorState;
+      double quality = NormalizedGiniCalculator.Calculate(targetValues, newOutput, out errorState);
+      if (errorState != OnlineCalculatorError.None) quality = 0.0;
+      SwitchNode(parent, constantNode, node);
+      // impact = 0 if no change
+      // impact < 0 if new solution is better
+      // impact > 0 if new solution is worse
+      return originalQuality - quality;
     }
   }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 8935)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
@@ -48,9 +49,10 @@
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
-      return calculator.CalculateReplacementValues(tree, Content.Model.Interpreter, Content.ProblemData);
+      return calculator.CalculateReplacementValues(tree, Content.Model.Interpreter, Content.ProblemData).ToDictionary(x => x.Item1, x => x.Item2);
     }
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
-      return calculator.CalculateImpactValues(tree, Content.Model.Interpreter, Content.ProblemData, 0, 0);
+      return calculator.CalculateImpactValues(tree, Content.Model.Interpreter, Content.ProblemData,
+                                              Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit).ToDictionary(x => x.Item1, x => x.Item2);
     }
 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
   partial class SymbolicRegressionSolutionErrorCharacteristicsCurveView {
     /// <summary> 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
   partial class SymbolicRegressionSolutionView {
     /// <summary> 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
   partial class VariableTrackbar {
     /// <summary> 
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs	(revision 8935)
@@ -1,9 +1,26 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
 using System.Linq;
-using System.Text;
 using System.Windows.Forms;
 using System.Windows.Forms.DataVisualization.Charting;
@@ -38,7 +55,7 @@
       boxPlotChart.Series["BoxPlot"]["BoxPlotShowMedian"] = "true";
       boxPlotChart.Series["BoxPlot"]["BoxPlotShowUnusualValues"] = "true";
-      boxPlotChart.ChartAreas[0].AxisY.Minimum = valuesArr.Min() ;
-      boxPlotChart.ChartAreas[0].AxisY.Maximum = valuesArr.Max() ;
-      
+      boxPlotChart.ChartAreas[0].AxisY.Minimum = valuesArr.Min();
+      boxPlotChart.ChartAreas[0].AxisY.Maximum = valuesArr.Max();
+
 
       trackBar.Minimum = (int)Math.Round(valuesArr.Min() * FACTOR);
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs	(revision 8935)
@@ -20,28 +20,29 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
+using HeuristicLab.Common;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
   public class SymbolicRegressionSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
-    public override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree,
-                                                                                               ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
-                                                                                               IDataAnalysisProblemData problemData) {
-      var replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
-        replacementValues[node] = CalculateReplacementValue(node, tree, interpreter, problemData);
-      }
-      return replacementValues;
+    public override IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateReplacementValues(ISymbolicExpressionTree tree,
+                                                                                                       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                       IDataAnalysisProblemData problemData) {
+      return from node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()
+             select new Tuple<ISymbolicExpressionTreeNode, double>(node, CalculateReplacementValue(node, tree, interpreter, problemData));
     }
 
-    public override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData regressionProblemData, double lowerEstimationLimit, double upperEstimationLimit) {
+    public override IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateImpactValues(ISymbolicExpressionTree tree,
+                                                                                                  ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                  IDataAnalysisProblemData regressionProblemData,
+                                                                                                  double lowerEstimationLimit, double upperEstimationLimit) {
       var problemData = (IRegressionProblemData)regressionProblemData;
       var dataset = problemData.Dataset;
       var rows = problemData.TrainingIndices.ToList();
       string targetVariable = problemData.TargetVariable;
-      var impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
       List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
-      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).ToArray();
+      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).LimitToRange(lowerEstimationLimit, upperEstimationLimit).ToArray();
       var targetValues = dataset.GetDoubleValues(targetVariable, rows).ToList();
       OnlineCalculatorError errorState;
@@ -49,21 +50,31 @@
       if (errorState != OnlineCalculatorError.None) originalR2 = 0.0;
 
-      foreach (ISymbolicExpressionTreeNode node in nodes) {
-        var parent = node.Parent;
-        var constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode());
-        constantNode.Value = CalculateReplacementValue(node, tree, interpreter, problemData);
-        ISymbolicExpressionTreeNode replacementNode = constantNode;
-        SwitchNode(parent, node, replacementNode);
-        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows);
-        double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);
-        if (errorState != OnlineCalculatorError.None) newR2 = 0.0;
+      return from node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList()
+             select new Tuple<ISymbolicExpressionTreeNode, double>(node, CalculateImpact(tree, originalR2, node, interpreter, problemData, lowerEstimationLimit, upperEstimationLimit));
+    }
 
-        // impact = 0 if no change
-        // impact < 0 if new solution is better
-        // impact > 0 if new solution is worse
-        impactValues[node] = originalR2 - newR2;
-        SwitchNode(parent, replacementNode, node);
-      }
-      return impactValues;
+    private static double CalculateImpact(ISymbolicExpressionTree tree, double originalQuality, ISymbolicExpressionTreeNode node,
+                                          ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IRegressionProblemData problemData,
+                                          double lowerEstimationLimit, double upperEstimationLimit) {
+      var dataset = problemData.Dataset;
+      var rows = problemData.TrainingIndices.ToList();
+      string targetVariable = problemData.TargetVariable;
+      var targetValues = dataset.GetDoubleValues(targetVariable, rows).ToList();
+
+      var parent = node.Parent;
+      var constantNode = (ConstantTreeNode)new Constant().CreateTreeNode();
+      constantNode.Value = CalculateReplacementValue(node, tree, interpreter, problemData);
+      SwitchNode(parent, node, constantNode);
+      var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)
+                                 .LimitToRange(lowerEstimationLimit, upperEstimationLimit)
+                                 .ToArray();
+      OnlineCalculatorError errorState;
+      double quality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);
+      if (errorState != OnlineCalculatorError.None) quality = 0.0;
+      SwitchNode(parent, constantNode, node);
+      // impact = 0 if no change
+      // impact < 0 if new solution is better
+      // impact > 0 if new solution is worse
+      return originalQuality - quality;
     }
   }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs	(revision 8935)
@@ -186,4 +186,5 @@
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.Controls.Add(this.splitContainer);
+      this.DoubleBuffered = true;
       this.Name = "InteractiveSymbolicDataAnalysisSolutionSimplifierView";
       this.Size = new System.Drawing.Size(564, 348);
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 8935)
@@ -96,4 +96,8 @@
       if (Content == null || Content.Model == null || Content.ProblemData == null) return;
       var tree = model;
+      CalculateReplacementNodesAndNodeImpacts(tree);
+    }
+
+    private void CalculateReplacementNodesAndNodeImpacts(ISymbolicExpressionTree tree) {
       var replacementValues = CalculateReplacementValues(tree);
       foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
@@ -117,26 +121,4 @@
     }
 
-    private void CalculateReplacementNodesAndNodeImpacts(ISymbolicExpressionTree tree) {
-      var replacementValues = CalculateReplacementValues(tree);
-      foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
-        replacementNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
-      }
-      nodeImpacts = CalculateImpactValues(tree);
-
-      if (!updateInProgress) {
-        // automatically fold all branches with impact = 0
-        List<ISymbolicExpressionTreeNode> nodeList = tree.Root.GetSubtree(0).IterateNodesPrefix().ToList();
-        foreach (var parent in nodeList) {
-          for (int subTreeIndex = 0; subTreeIndex < parent.SubtreeCount; subTreeIndex++) {
-            var child = parent.GetSubtree(subTreeIndex);
-            if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(0.0)) {
-              SwitchNodeWithReplacementNode(parent, subTreeIndex);
-            }
-          }
-        }
-      }
-      PaintModel();
-    }
-
     private void PaintModel() {
       // show only interesting part of solution 
@@ -149,9 +131,7 @@
     protected abstract void UpdateModel(ISymbolicExpressionTree tree);
 
-    private ConstantTreeNode MakeConstantTreeNode(double value) {
-      Constant constant = new Constant();
-      constant.MinValue = value - 1;
-      constant.MaxValue = value + 1;
-      ConstantTreeNode constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
+    private static ConstantTreeNode MakeConstantTreeNode(double value) {
+      var constant = new Constant { MinValue = value - 1, MaxValue = value + 1 };
+      var constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
       constantTreeNode.Value = value;
       return constantTreeNode;
@@ -164,4 +144,6 @@
       if (symbExprTreeNode == null) return;
       var tree = model;
+
+      bool update = false;
       // check if the node value/weight has been altered
       // if so, the first double click will return the node to its original value/weight/variable name
@@ -171,35 +153,36 @@
         variable.VariableName = originalVariableNames[symbExprTreeNode];
         originalVariableNames.Remove(variable);
+        update = true;
+      } else if (originalValues.ContainsKey(symbExprTreeNode)) {
+        double value = originalValues[symbExprTreeNode];
+        if (symbExprTreeNode.Symbol is Constant) {
+          var constantTreeNode = (ConstantTreeNode)symbExprTreeNode;
+          constantTreeNode.Value = value;
+        } else if (symbExprTreeNode.Symbol is Variable) {
+          var variable = (VariableTreeNode)symbExprTreeNode;
+          variable.Weight = value;
+        }
+        originalValues.Remove(symbExprTreeNode);
+        update = true;
+      } else if (replacementNodes.ContainsKey(symbExprTreeNode)) {
+        foreach (var treeNode in tree.IterateNodesPostfix()) {
+          for (int i = 0; i < treeNode.SubtreeCount; i++) {
+            var subtree = treeNode.GetSubtree(i);
+            if (subtree == symbExprTreeNode) {
+              SwitchNodeWithReplacementNode(treeNode, i);
+              // show only interesting part of solution 
+              treeChart.Tree = tree.Root.SubtreeCount > 1
+                                 ? new SymbolicExpressionTree(tree.Root)
+                                 : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0));
+              update = true;
+            }
+          }
+          if (update) break;
+        }
+      }
+      if (update) {
         updateInProgress = true;
         UpdateModel(tree);
         updateInProgress = false;
-        return;
-      }
-      if (originalValues.ContainsKey(symbExprTreeNode)) {
-        double value = originalValues[symbExprTreeNode];
-        if (symbExprTreeNode.Symbol is Constant)
-          ((ConstantTreeNode)symbExprTreeNode).Value = value;
-        else if (symbExprTreeNode.Symbol is Variable)
-          ((VariableTreeNode)symbExprTreeNode).Weight = value;
-        originalValues.Remove(symbExprTreeNode);
-        updateInProgress = true;
-        UpdateModel(tree);
-        updateInProgress = false;
-        return;
-      }
-      foreach (SymbolicExpressionTreeNode treeNode in tree.IterateNodesPostfix()) {
-        for (int i = 0; i < treeNode.SubtreeCount; i++) {
-          ISymbolicExpressionTreeNode subTree = treeNode.GetSubtree(i);
-          // only allow to replace nodes for which a replacement value is known (replacement value for ADF nodes are not available)
-          if (subTree == symbExprTreeNode && replacementNodes.ContainsKey(subTree)) {
-            SwitchNodeWithReplacementNode(treeNode, i);
-            // show only interesting part of solution 
-            treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0));
-            updateInProgress = true;
-            UpdateModel(tree);
-            updateInProgress = false;
-            return; // break all loops
-          }
-        }
       }
     }
@@ -222,7 +205,7 @@
 
       if (node is VariableTreeNode) {
-        var variable = dialog.Content as VariableTreeNode;
-        var weight = double.Parse(dialog.NewValueTextBox.Text);
-        var name = (string)dialog.VariableNameComboBox.SelectedItem;
+        var variable = (VariableTreeNode)node;
+        var weight = double.Parse(dialog.newValueTextBox.Text);
+        var name = (string)dialog.variableNamesCombo.SelectedItem;
         if (!variable.Weight.Equals(weight)) {
           flag1 = true;
@@ -236,6 +219,6 @@
         }
       } else if (node is ConstantTreeNode) {
-        var constant = dialog.Content as ConstantTreeNode;
-        var value = double.Parse(dialog.NewValueTextBox.Text);
+        var constant = (ConstantTreeNode)node;
+        var value = double.Parse(dialog.newValueTextBox.Text);
         if (!constant.Value.Equals(value)) {
           flag1 = true;
@@ -355,5 +338,4 @@
       } else if (e.Error != null) {
         // There was an error during the operation.
-        // Error-handling
       } else {
         // The operation completed normally. We can update the model
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿using System.Windows.Forms;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Windows.Forms;
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
@@ -26,4 +47,5 @@
     /// </summary>
     private void InitializeComponent() {
+      this.DoubleBuffered = true;
       this.insertNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.changeValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -131,4 +153,14 @@
       this.pasteToolStripMenuItem.Text = "Paste";
       this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Clicked);
+      //
+      // contextMenuStrip
+      //
+      this.contextMenuStrip.Opened += this.contextMenuStrip_Opened;
+      this.contextMenuStrip.Items.AddRange(new ToolStripItem[] { insertNodeToolStripMenuItem,
+                                                                 changeValueToolStripMenuItem, 
+                                                                 copyToolStripMenuItem, 
+                                                                 cutToolStripMenuItem, 
+                                                                 deleteToolStripMenuItem, 
+                                                                 pasteToolStripMenuItem });
       // 
       // treeStatusLabel
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs	(revision 8935)
@@ -40,12 +40,6 @@
       InitializeComponent();
       // add extra actions in the context menu strips
-      this.contextMenuStrip.Opened += this.contextMenuStrip_Opened;
-      this.contextMenuStrip.Items.AddRange(new ToolStripItem[] {
-                                               insertNodeToolStripMenuItem,
-                                               changeValueToolStripMenuItem, 
-                                               copyToolStripMenuItem, 
-                                               cutToolStripMenuItem, 
-                                               deleteToolStripMenuItem, 
-                                               pasteToolStripMenuItem });
+
+
       lastSelected = null;
       currSelected = null;
@@ -53,8 +47,5 @@
     }
 
-    public bool TreeValid {
-      get { return TreeState.Valid == treeState; }
-    }
-
+    public bool TreeValid { get { return TreeState.Valid == treeState; } }
     // expose an additional event for signaling to the parent view when the tree structure was modified
     // the emitting of the signal is conditional on the tree being valid, otherwise only a Repaint is issued
@@ -66,7 +57,6 @@
         treeState = TreeState.Valid;
         var changed = SymbolicExpressionTreeChanged;
-        if (changed != null) {
+        if (changed != null)
           changed(sender, e);
-        }
       } else {
         treeStatusValue.Text = "Invalid";
@@ -80,49 +70,32 @@
       var menu = sender as ContextMenuStrip;
       if (menu == null) return;
-      var point = menu.SourceControl.PointToClient(Cursor.Position);
-      var visualNode = FindVisualSymbolicExpressionTreeNodeAt(point.X, point.Y);
-      if (visualNode != null) {
-        lastSelected = currSelected;
-        if (lastSelected != null) lastSelected.LineColor = Color.Black;
-        currSelected = visualNode;
-        currSelected.LineColor = Color.LightGreen;
-        EnableTreeEditingMenuItems();
-        OnSymbolicExpressionTreeNodeClicked(currSelected, new MouseEventArgs(MouseButtons.Right, 1, point.X, point.Y, 0));
+      if (currSelected == null) {
+        insertNodeToolStripMenuItem.Visible = false;
+        changeValueToolStripMenuItem.Visible = false;
+        copyToolStripMenuItem.Visible = false;
+        cutToolStripMenuItem.Visible = false;
+        deleteToolStripMenuItem.Visible = false;
+        pasteToolStripMenuItem.Visible = false;
       } else {
-        DisableTreeEditingMenuItems();
-      }
-    }
-
-    private void DisableTreeEditingMenuItems() {
-      insertNodeToolStripMenuItem.Visible = false;
-      changeValueToolStripMenuItem.Visible = false;
-      copyToolStripMenuItem.Visible = false;
-      cutToolStripMenuItem.Visible = false;
-      deleteToolStripMenuItem.Visible = false;
-      pasteToolStripMenuItem.Visible = false;
-    }
-
-    private void EnableTreeEditingMenuItems() {
-
-      var node = currSelected.SymbolicExpressionTreeNode;
-      changeValueToolStripMenuItem.Visible = (node is SymbolicExpressionTreeTerminalNode);
-      insertNodeToolStripMenuItem.Visible = !changeValueToolStripMenuItem.Visible;
-      copyToolStripMenuItem.Visible = true;
-      cutToolStripMenuItem.Visible = true;
-      deleteToolStripMenuItem.Visible = true;
-      pasteToolStripMenuItem.Visible = (lastOp == EditOp.CopyNode || lastOp == EditOp.CopySubtree || lastOp == EditOp.CutNode || lastOp == EditOp.CutSubtree) && insertNodeToolStripMenuItem.Visible;
-    }
-
-
-    protected override void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
-      VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
-      if (visualTreeNode != null) {
-        lastSelected = currSelected;
-        if (lastSelected != null) lastSelected.LineColor = Color.Black;
-        currSelected = visualTreeNode;
-        currSelected.LineColor = Color.LightGreen;
-      }
-      Repaint();
-      base.SymbolicExpressionTreeChart_MouseClick(sender, e);
+        var node = currSelected.SymbolicExpressionTreeNode;
+        changeValueToolStripMenuItem.Visible = (node is SymbolicExpressionTreeTerminalNode);
+        insertNodeToolStripMenuItem.Visible = !changeValueToolStripMenuItem.Visible;
+        copyToolStripMenuItem.Visible = true;
+        cutToolStripMenuItem.Visible = true;
+        deleteToolStripMenuItem.Visible = true;
+        pasteToolStripMenuItem.Visible = tempNode != null && insertNodeToolStripMenuItem.Visible;
+      }
+    }
+
+    protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
+      var visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
+      if (visualTreeNode == null || visualTreeNode == currSelected) return;
+      lastSelected = currSelected;
+      if (lastSelected != null)
+        lastSelected.LineColor = Color.Black;
+      currSelected = visualTreeNode;
+      currSelected.LineColor = Color.LightGreen;
+      Repaint();
+      base.OnSymbolicExpressionTreeNodeClicked(sender, e);
     }
 
@@ -131,8 +104,9 @@
       var node = currSelected.SymbolicExpressionTreeNode;
 
-      var dialog = new InsertNodeDialog();
-      dialog.SetAllowedSymbols(node.Grammar.AllowedSymbols.Where(s => s.Enabled && s.InitialFrequency > 0.0 && !(s is ProgramRootSymbol || s is StartSymbol || s is Defun)));
-      dialog.DialogValidated += OnInsertNodeDialogValidated;
-      dialog.ShowDialog(this);
+      using (var dialog = new InsertNodeDialog()) {
+        dialog.SetAllowedSymbols(node.Grammar.AllowedSymbols.Where(s => s.Enabled && s.InitialFrequency > 0.0 && !(s is ProgramRootSymbol || s is StartSymbol || s is Defun)));
+        dialog.DialogValidated += InsertNodeDialog_Validated;
+        dialog.ShowDialog(this);
+      }
     }
 
@@ -140,17 +114,23 @@
       if (currSelected == null) return;
       var node = currSelected.SymbolicExpressionTreeNode;
-      var dialog = new ValueChangeDialog();
-      dialog.SetContent(node);
-      dialog.DialogValidated += OnChangeValueDialogValidated;
-      dialog.ShowDialog(this);
+      using (var dialog = new ValueChangeDialog()) {
+        dialog.SetContent(node);
+        dialog.DialogValidated += ChangeValueDialog_Validated;
+        dialog.ShowDialog(this);
+      }
     }
 
     public event EventHandler SymbolicExpressionTreeNodeChanged;
-
-    private void OnChangeValueDialogValidated(object sender, EventArgs e) {
-      SymbolicExpressionTreeNodeChanged(sender, e);
-    }
-
-    private void OnInsertNodeDialogValidated(object sender, EventArgs e) {
+    private void OnSymbolicExpressionTreeNodeChanged(object sender, EventArgs e) {
+      var changed = SymbolicExpressionTreeNodeChanged;
+      if (changed != null)
+        SymbolicExpressionTreeNodeChanged(sender, e);
+    }
+
+    private void ChangeValueDialog_Validated(object sender, EventArgs e) {
+      OnSymbolicExpressionTreeNodeChanged(sender, e);
+    }
+
+    private void InsertNodeDialog_Validated(object sender, EventArgs e) {
       var dialog = (InsertNodeDialog)sender;
       var symbol = dialog.SelectedSymbol();
@@ -172,5 +152,4 @@
           }
         }
-        // we assume that there is no case in which the parents subtrees get transferred to node, but node doesn't get added as a subtree of parent
       }
       if (parent.Symbol.MaximumArity > parent.SubtreeCount) {
@@ -210,7 +189,6 @@
       lastOp = EditOp.CopyNode;
       tempNode = currSelected.SymbolicExpressionTreeNode;
-      var visualNode = visualTreeNodes[tempNode];
-      visualNode.LineColor = Color.LightGray;
-      visualNode.TextColor = Color.LightGray;
+      currSelected.LineColor = Color.LightGray;
+      currSelected.TextColor = Color.LightGray;
       Repaint();
     }
@@ -223,9 +201,8 @@
         visualNode.LineColor = Color.LightGray;
         visualNode.TextColor = Color.LightGray;
-        if (node.SubtreeCount > 0) {
-          foreach (var subtree in node.Subtrees) {
-            var visualLine = visualLines[new Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(node, subtree)];
-            visualLine.LineColor = Color.LightGray;
-          }
+        if (node.SubtreeCount <= 0) continue;
+        foreach (var subtree in node.Subtrees) {
+          var visualLine = visualLines[new Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(node, subtree)];
+          visualLine.LineColor = Color.LightGray;
         }
       }
@@ -237,4 +214,6 @@
       var node = currSelected.SymbolicExpressionTreeNode;
       var parent = node.Parent;
+      if (parent == null || parent.Symbol is StartSymbol || parent.Symbol is ProgramRootSymbol)
+        return; // the operation would result in the deletion of the entire tree
       if (parent.Symbol.MaximumArity >= node.SubtreeCount + parent.SubtreeCount - 1) { // -1 because tempNode will be removed
         parent.RemoveSubtree(parent.IndexOfSubtree(node));
@@ -244,8 +223,6 @@
           parent.AddSubtree(child);
         }
-      } else {
-        // if the node cannot be deleted without breaking the tree, do nothing
-        // TODO: decide what to do
-      }
+      }
+      currSelected = null; // because the currently selected node was just deleted
       OnSymbolicExpressionTreeChanged(sender, e);
     }
@@ -255,5 +232,8 @@
       var node = currSelected.SymbolicExpressionTreeNode;
       var parent = node.Parent;
+      if (parent == null || parent.Symbol is StartSymbol || parent.Symbol is ProgramRootSymbol)
+        return; // the operation makes no sense as it would result in the deletion of the entire tree
       parent.RemoveSubtree(parent.IndexOfSubtree(node));
+      currSelected = null; // because the currently selected node was just deleted
       OnSymbolicExpressionTreeChanged(sender, e);
     }
@@ -270,7 +250,8 @@
         switch (lastOp) {
           case (EditOp.CutNode): {
-              // cut node
+              // when cutting a node from the tree, it's children become children of it's parent
               var parent = tempNode.Parent;
               // arity checks to see if parent can accept node's children (we assume the grammar is already ok with that)
+              // (otherise, the 'cut' part of the operation will just not do anything)
               if (parent.Symbol.MaximumArity >= tempNode.SubtreeCount + parent.SubtreeCount - 1) {
                 // -1 because tempNode will be removed
@@ -282,4 +263,5 @@
                 }
                 lastOp = EditOp.CopyNode;
+                currSelected = null;
               }
               break;
@@ -287,35 +269,29 @@
           case (EditOp.CutSubtree): {
               // cut subtree
-              tempNode.Parent.RemoveSubtree(tempNode.Parent.IndexOfSubtree(tempNode));
-              lastOp = EditOp.CopySubtree; // do this so the next paste will actually perform a copy
+              var parent = tempNode.Parent;
+              parent.RemoveSubtree(parent.IndexOfSubtree(tempNode));
+              lastOp = EditOp.CopySubtree; // do this so the next paste will actually perform a copy   
+              currSelected = null;
               break;
             }
           case (EditOp.CopyNode): {
               // copy node
-              var clone = tempNode.Clone() as ISymbolicExpressionTreeNode; // should never be null
+              var clone = (SymbolicExpressionTreeNode)tempNode.Clone(); // should never be null
               clone.Parent = tempNode.Parent;
               tempNode = clone;
-              if (tempNode != null && tempNode.SubtreeCount > 0) {
-                for (int i = tempNode.SubtreeCount - 1; i >= 0; --i)
-                  tempNode.RemoveSubtree(i);
-              }
+              for (int i = tempNode.SubtreeCount - 1; i >= 0; --i) tempNode.RemoveSubtree(i);
               break;
             }
           case (EditOp.CopySubtree): {
               // copy subtree
-              var clone = tempNode.Clone() as ISymbolicExpressionTreeNode;
-              if (clone != null) {
-                clone.Parent = tempNode.Parent;
-                tempNode = clone;
-              }
+              var clone = (SymbolicExpressionTreeNode)tempNode.Clone();
+              clone.Parent = tempNode.Parent;
+              tempNode = clone;
               break;
             }
         }
         node.AddSubtree(tempNode);
-        Tree = Tree;
-        // hack in order to trigger the reinitialization of the dictionaries after new nodes appeared in the graph
+        Tree = Tree; // hack in order to trigger the reinitialization of the dictionaries after new nodes appeared in the graph
         OnSymbolicExpressionTreeChanged(sender, e);
-      } else {
-        // throw exception or show a warning to the user about invalid arity
       }
     }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8935)
@@ -53,4 +53,6 @@
       this.variableNameLabel = new System.Windows.Forms.Label();
       this.variableNamesCombo = new System.Windows.Forms.ComboBox();
+      this.okButton = new System.Windows.Forms.Button();
+      this.cancelButton = new System.Windows.Forms.Button();
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
       this.SuspendLayout();
@@ -59,5 +61,5 @@
       // 
       this.originalValueLabel.AutoSize = true;
-      this.originalValueLabel.Location = new System.Drawing.Point(14, 15);
+      this.originalValueLabel.Location = new System.Drawing.Point(12, 45);
       this.originalValueLabel.Name = "originalValueLabel";
       this.originalValueLabel.Size = new System.Drawing.Size(72, 13);
@@ -67,5 +69,5 @@
       // oldValueTextBox
       // 
-      this.oldValueTextBox.Location = new System.Drawing.Point(123, 12);
+      this.oldValueTextBox.Location = new System.Drawing.Point(123, 42);
       this.oldValueTextBox.Name = "oldValueTextBox";
       this.oldValueTextBox.ReadOnly = true;
@@ -75,5 +77,5 @@
       // newValueTextBox
       // 
-      this.newValueTextBox.Location = new System.Drawing.Point(123, 38);
+      this.newValueTextBox.Location = new System.Drawing.Point(123, 82);
       this.newValueTextBox.Name = "newValueTextBox";
       this.newValueTextBox.Size = new System.Drawing.Size(131, 20);
@@ -86,5 +88,5 @@
       // 
       this.newValueLabel.AutoSize = true;
-      this.newValueLabel.Location = new System.Drawing.Point(14, 41);
+      this.newValueLabel.Location = new System.Drawing.Point(12, 85);
       this.newValueLabel.Name = "newValueLabel";
       this.newValueLabel.Size = new System.Drawing.Size(59, 13);
@@ -101,5 +103,5 @@
       // 
       this.variableNameLabel.AutoSize = true;
-      this.variableNameLabel.Location = new System.Drawing.Point(14, 74);
+      this.variableNameLabel.Location = new System.Drawing.Point(12, 7);
       this.variableNameLabel.Name = "variableNameLabel";
       this.variableNameLabel.Size = new System.Drawing.Size(76, 13);
@@ -112,5 +114,5 @@
       this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
       this.variableNamesCombo.FormattingEnabled = true;
-      this.variableNamesCombo.Location = new System.Drawing.Point(123, 71);
+      this.variableNamesCombo.Location = new System.Drawing.Point(123, 4);
       this.variableNamesCombo.Name = "variableNamesCombo";
       this.variableNamesCombo.Size = new System.Drawing.Size(131, 21);
@@ -121,4 +123,26 @@
       this.variableNamesCombo.Validated += new System.EventHandler(this.variableNamesCombo_Validated);
       // 
+      // okButton
+      // 
+      this.okButton.Location = new System.Drawing.Point(15, 119);
+      this.okButton.Name = "okButton";
+      this.okButton.Size = new System.Drawing.Size(75, 23);
+      this.okButton.TabIndex = 8;
+      this.okButton.Text = "OK";
+      this.okButton.UseVisualStyleBackColor = true;
+      this.okButton.Click += new System.EventHandler(this.okButton_Click);
+      // 
+      // cancelButton
+      // 
+      this.cancelButton.CausesValidation = false;
+      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+      this.cancelButton.Location = new System.Drawing.Point(179, 119);
+      this.cancelButton.Name = "cancelButton";
+      this.cancelButton.Size = new System.Drawing.Size(75, 23);
+      this.cancelButton.TabIndex = 9;
+      this.cancelButton.Text = "Cancel";
+      this.cancelButton.UseVisualStyleBackColor = true;
+      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+      // 
       // ValueChangeDialog
       // 
@@ -126,5 +150,9 @@
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.AutoSize = true;
-      this.ClientSize = new System.Drawing.Size(269, 103);
+      this.CancelButton = this.cancelButton;
+      this.ClientSize = new System.Drawing.Size(269, 154);
+      this.ControlBox = false;
+      this.Controls.Add(this.cancelButton);
+      this.Controls.Add(this.okButton);
       this.Controls.Add(this.variableNamesCombo);
       this.Controls.Add(this.variableNameLabel);
@@ -133,4 +161,5 @@
       this.Controls.Add(this.oldValueTextBox);
       this.Controls.Add(this.originalValueLabel);
+      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
       this.MaximizeBox = false;
       this.MinimizeBox = false;
@@ -151,9 +180,11 @@
     private System.Windows.Forms.Label originalValueLabel;
     private System.Windows.Forms.TextBox oldValueTextBox;
-    private System.Windows.Forms.TextBox newValueTextBox;
     private System.Windows.Forms.Label newValueLabel;
     private System.Windows.Forms.ErrorProvider errorProvider;
-    private System.Windows.Forms.ComboBox variableNamesCombo;
     private System.Windows.Forms.Label variableNameLabel;
+    private System.Windows.Forms.Button cancelButton;
+    private System.Windows.Forms.Button okButton;
+    public System.Windows.Forms.TextBox newValueTextBox;
+    public System.Windows.Forms.ComboBox variableNamesCombo;
   }
 }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8935)
@@ -29,51 +29,13 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
   public partial class ValueChangeDialog : Form {
-    private ISymbolicExpressionTreeNode _content;
+    private ISymbolicExpressionTreeNode content;
     public ISymbolicExpressionTreeNode Content {
-      get { return _content; }
+      get { return content; }
       set {
         if (InvokeRequired)
-          Invoke(new Action<SymbolicExpressionTreeNode>(x => _content = x), value);
+          Invoke(new Action<SymbolicExpressionTreeNode>(x => content = x), value);
         else
-          _content = value;
+          content = value;
       }
-    }
-
-    public string Caption {
-      get { return this.Text; }
-      set {
-        if (InvokeRequired)
-          Invoke(new Action<string>(x => this.Caption = x), value);
-        else
-          this.Text = value;
-      }
-    }
-
-    public string OldValue {
-      get { return oldValueTextBox.Text; }
-      set {
-        if (InvokeRequired)
-          Invoke(new Action<string>(x => this.NewValue = x), value);
-        else
-          oldValueTextBox.Text = value;
-      }
-    }
-
-    public string NewValue {
-      get { return newValueTextBox.Text; }
-      set {
-        if (InvokeRequired)
-          Invoke(new Action<string>(x => this.NewValue = x), value);
-        else
-          newValueTextBox.Text = value;
-      }
-    }
-
-    public TextBox NewValueTextBox {
-      get { return newValueTextBox; }
-    }
-
-    public ComboBox VariableNameComboBox {
-      get { return variableNamesCombo; }
     }
 
@@ -86,8 +48,7 @@
       Content = content;
       if (Content is VariableTreeNode) {
-        Caption = "Change variable name or weight";
+        this.Text = "Change variable name or weight";
         var variable = Content as VariableTreeNode;
-        OldValue = Math.Round(variable.Weight, 4).ToString();
-        NewValue = OldValue;
+        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(variable.Weight, 4).ToString();
         // add a dropbox containing all the available variable names
         variableNameLabel.Visible = true;
@@ -95,11 +56,8 @@
         foreach (var name in variable.Symbol.VariableNames) variableNamesCombo.Items.Add(name);
         variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variable.VariableName);
-        //        variableNamesCombo.SelectedText = variable.VariableName;
-        //        variableNamesCombo.SelectedIndex = 0;
       } else if (Content is ConstantTreeNode) {
-        Caption = "Change constant value";
+        this.Text = "Change constant value";
         var constant = Content as ConstantTreeNode;
-        OldValue = Math.Round(constant.Value, 4).ToString();
-        NewValue = OldValue;
+        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constant.Value, 4).ToString();
       }
     }
@@ -155,5 +113,5 @@
       if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         if (!ValidateChildren()) return;
-        DialogValidated(this, e);
+        OnDialogValidated(this, e); // emit validated effect
         Close();
       }
@@ -161,4 +119,21 @@
 
     public event EventHandler DialogValidated;
+    private void OnDialogValidated(object sender, EventArgs e) {
+      var dialogValidated = DialogValidated;
+      if (dialogValidated != null)
+        dialogValidated(sender, e);
+    }
+
+    private void cancelButton_Click(object sender, EventArgs e) {
+      Close();
+    }
+
+    private void okButton_Click(object sender, EventArgs e) {
+      if (ValidateChildren()) {
+        OnDialogValidated(this, e);
+        Close();
+      }
+    }
+
   }
 }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
   partial class InsertNodeDialog {
     /// <summary>
@@ -34,4 +55,6 @@
       this.constantValueLabel = new System.Windows.Forms.Label();
       this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+      this.okButton = new System.Windows.Forms.Button();
+      this.cancelButton = new System.Windows.Forms.Button();
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
       this.SuspendLayout();
@@ -70,5 +93,5 @@
       // 
       this.variableNameLabel.AutoSize = true;
-      this.variableNameLabel.Location = new System.Drawing.Point(13, 77);
+      this.variableNameLabel.Location = new System.Drawing.Point(13, 74);
       this.variableNameLabel.Name = "variableNameLabel";
       this.variableNameLabel.Size = new System.Drawing.Size(35, 13);
@@ -81,5 +104,5 @@
       this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
       this.variableNamesCombo.FormattingEnabled = true;
-      this.variableNamesCombo.Location = new System.Drawing.Point(120, 74);
+      this.variableNamesCombo.Location = new System.Drawing.Point(120, 71);
       this.variableNamesCombo.Name = "variableNamesCombo";
       this.variableNamesCombo.Size = new System.Drawing.Size(108, 21);
@@ -123,9 +146,34 @@
       this.errorProvider.RightToLeft = true;
       // 
+      // okButton
+      // 
+      this.okButton.Location = new System.Drawing.Point(12, 112);
+      this.okButton.Name = "okButton";
+      this.okButton.Size = new System.Drawing.Size(75, 23);
+      this.okButton.TabIndex = 9;
+      this.okButton.Text = "OK";
+      this.okButton.UseVisualStyleBackColor = true;
+      this.okButton.Click += new System.EventHandler(this.okButton_Click);
+      // 
+      // cancelButton
+      // 
+      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+      this.cancelButton.Location = new System.Drawing.Point(153, 112);
+      this.cancelButton.Name = "cancelButton";
+      this.cancelButton.Size = new System.Drawing.Size(75, 23);
+      this.cancelButton.TabIndex = 10;
+      this.cancelButton.Text = "Cancel";
+      this.cancelButton.UseVisualStyleBackColor = true;
+      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+      // 
       // InsertNodeDialog
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-      this.ClientSize = new System.Drawing.Size(240, 107);
+      this.CancelButton = this.cancelButton;
+      this.ClientSize = new System.Drawing.Size(240, 147);
+      this.ControlBox = false;
+      this.Controls.Add(this.cancelButton);
+      this.Controls.Add(this.okButton);
       this.Controls.Add(this.constantValueLabel);
       this.Controls.Add(this.constantValueTextBox);
@@ -136,4 +184,5 @@
       this.Controls.Add(this.allowedSymbolsCombo);
       this.Controls.Add(this.nodeSymbolLabel);
+      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
       this.Name = "InsertNodeDialog";
       this.Text = "SymbolicExpressionTreeNodeInsertDialog";
@@ -156,4 +205,6 @@
     internal System.Windows.Forms.TextBox variableWeightTextBox;
     internal System.Windows.Forms.ComboBox variableNamesCombo;
+    private System.Windows.Forms.Button cancelButton;
+    private System.Windows.Forms.Button okButton;
   }
 }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -9,14 +30,4 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
   public partial class InsertNodeDialog : Form {
-    public string Caption {
-      get { return this.Text; }
-      set {
-        if (InvokeRequired)
-          Invoke(new Action<string>(x => this.Caption = x), value);
-        else
-          this.Text = value;
-      }
-    }
-
     public InsertNodeDialog() {
       InitializeComponent();
@@ -55,4 +66,11 @@
         constantValueTextBox.Visible = false;
         // add controls to the dialog for changing the variable name or weight
+      } else {
+        variableNameLabel.Visible = false;
+        variableNamesCombo.Visible = false;
+        variableWeightLabel.Visible = false;
+        variableWeightTextBox.Visible = false;
+        constantValueLabel.Visible = false;
+        constantValueTextBox.Visible = false;
       }
     }
@@ -90,4 +108,9 @@
 
     public event EventHandler DialogValidated;
+    private void OnDialogValidated(object sender, EventArgs e) {
+      var dialogValidated = DialogValidated;
+      if (dialogValidated != null)
+        dialogValidated(sender, e);
+    }
 
     private void childControl_KeyDown(object sender, KeyEventArgs e) {
@@ -98,9 +121,20 @@
       if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
         if (ValidateChildren()) {
-          DialogValidated(this, e);
+          OnDialogValidated(this, e);
           Close();
         }
       }
     }
+
+    private void okButton_Click(object sender, EventArgs e) {
+      if (ValidateChildren()) {
+        OnDialogValidated(this, e);
+        Close();
+      }
+    }
+
+    private void cancelButton_Click(object sender, EventArgs e) {
+      Close();
+    }
   }
 }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 8935)
@@ -204,5 +204,4 @@
     <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" />
     <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" />
-    <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" />
     <Compile Include="Interpreter\InterpreterState.cs" />
     <Compile Include="Interpreter\OpCodes.cs" />
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs	(revision 8935)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using HeuristicLab.Common;
@@ -25,9 +26,14 @@
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
-  public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator : ISymbolicDataAnalysisSolutionImpactValuesCalculator {
-    public abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData);
-    public abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData, double lowerEstimationLimit, double upperEstimationLimit);
+  public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator {
+    public abstract IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateReplacementValues(ISymbolicExpressionTree tree,
+                                                                                                       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                       IDataAnalysisProblemData problemData);
+    public abstract IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateImpactValues(ISymbolicExpressionTree tree,
+                                                                                                  ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+                                                                                                  IDataAnalysisProblemData problemData,
+                                                                                                  double lowerEstimationLimit, double upperEstimationLimit);
 
-    protected void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
+    protected static void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
       for (int i = 0; i < root.SubtreeCount; i++) {
         if (root.GetSubtree(i) == oldBranch) {
@@ -39,11 +45,12 @@
     }
 
-    protected double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData) {
-      var root = new ProgramRootSymbol().CreateTreeNode();
-      var start = new StartSymbol().CreateTreeNode();
-      root.AddSubtree(start);
-      start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
+    protected static double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree,
+                                                      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData) {
+      var rootSymbol = new ProgramRootSymbol().CreateTreeNode();
+      var startSymbol = new StartSymbol().CreateTreeNode();
+      rootSymbol.AddSubtree(startSymbol);
+      startSymbol.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
       var rows = problemData.TrainingIndices;
-      var tempTree = new SymbolicExpressionTree(root);
+      var tempTree = new SymbolicExpressionTree(rootSymbol);
       return interpreter.GetSymbolicExpressionTreeValues(tempTree, problemData.Dataset, rows).Median();
     }
Index: /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedSymbol.cs
===================================================================
--- /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedSymbol.cs	(revision 8934)
+++ /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedSymbol.cs	(revision 8935)
@@ -1,3 +1,24 @@
-﻿using HeuristicLab.Common;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
