Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs	(revision 7226)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs	(revision 7227)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Linq;
 using HeuristicLab.Analysis;
@@ -29,5 +30,4 @@
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using System;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
@@ -37,5 +37,5 @@
   [Item("SymbolicExpressionTreeLengthAnalyzer", "An operator that tracks tree lengths of Symbolic Expression Trees")]
   [StorableClass]
-  public sealed class SymbolicExpressionTreeLengthAnalyzer : SingleSuccessorOperator, ISymbolicExpressionTreeAnalyzer {
+  public sealed class SymbolicExpressionTreeLengthAnalyzer : SingleSuccessorOperator, ISymbolicExpressionTreeAnalyzer, IStatefulItem {
     private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
@@ -91,5 +91,4 @@
     private SymbolicExpressionTreeLengthAnalyzer(SymbolicExpressionTreeLengthAnalyzer original, Cloner cloner)
       : base(original, cloner) {
-      AfterDeserialization();
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -107,5 +106,8 @@
       Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
 
-      AfterDeserialization();
+      SymbolicExpressionTreeLengthsParameter.Hidden = true;
+      SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true;
+      ResultsParameter.Hidden = true;
+      UpdateCounterParameter.Hidden = true;
     }
 
@@ -119,13 +121,18 @@
         Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
       }
-      if (Parameters.ContainsKey(UpdateCounterParameterName))
-        Parameters.Remove(UpdateCounterParameterName);
-      Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
-
-      SymbolicExpressionTreeLengthsParameter.Hidden = true;
-      SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true;
-      ResultsParameter.Hidden = true;
-      UpdateCounterParameter.Hidden = true;
-    }
+      if (!Parameters.ContainsKey(UpdateCounterParameterName)) {
+        Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0)));
+        UpdateCounterParameter.Hidden = true;
+      }
+    }
+
+    #region IStatefulItem members
+    public void InitializeState() {
+      UpdateCounter.Value = 0;
+    }
+    public void ClearState() {
+      UpdateCounter.Value = 0;
+    }
+    #endregion
 
     public override IOperation Apply() {
@@ -222,29 +229,4 @@
 
         if (storeHistory) {
-          // store tree lengths for each generation
-          var historyDataRow = new DataRow("Tree lengths", "", treeLengthsTableRow.Values);
-          historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
-          historyDataRow.VisualProperties.ExactBins = false;
-          historyDataRow.VisualProperties.Bins = range;
-          historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor;
-          historyDataRow.VisualProperties.IsVisibleInLegend = false;
-          var historyTable = new DataTable("Tree lengths");
-          historyTable.Rows.Add(historyDataRow);
-          // visual properties for the X-axis
-          historyTable.VisualProperties.XAxisMinimumAuto = false;
-          historyTable.VisualProperties.XAxisMaximumAuto = false;
-          historyTable.VisualProperties.XAxisMinimumFixedValue = 0.0;
-          if (maxLength > maximumAllowedTreeLength + 1)
-            historyTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed
-          else
-            historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;
-          historyTable.VisualProperties.XAxisTitle = xAxisTitle;
-          // visual properties for the Y-axis
-          historyTable.VisualProperties.YAxisMinimumAuto = false;
-          historyTable.VisualProperties.YAxisMaximumAuto = false;
-          historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0;
-          historyTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue;
-          historyTable.VisualProperties.YAxisTitle = yAxisTitle;
-
           var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue;
           if (treeLengthsHistory == null) {
@@ -252,6 +234,5 @@
             SymbolicExpressionTreeLengthsHistoryParameter.ActualValue = treeLengthsHistory;
           }
-
-          treeLengthsHistory.Add(historyTable);
+          treeLengthsHistory.Add((DataTable)treeLengthsTable.Clone());
 
           if (!results.ContainsKey(treeLengthHistoryTableName)) {
