Index: trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs
===================================================================
--- trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs	(revision 6201)
+++ trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs	(revision 6205)
@@ -21,7 +21,9 @@
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.Reflection;
-using System.Collections;
+using System.Threading;
 
 namespace HeuristicLab.Common {
@@ -35,33 +37,31 @@
     /// Types not collected:
     ///   * System.Delegate
-    ///   * System.EventHandler (+ System.EventHandler<T>)
+    ///   * System.Reflection.Pointer
     ///   * Primitives (Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, Single)
     ///   * string, decimal
-    ///   * Arrays of primitives (+ string, decimal)
-    /// Types of which the fields are not further collected:
-    ///   * System.Type
-    ///   * System.Threading.ThreadLocal<T>
+    ///   * Arrays of types not collected
+    ///   
+    /// Dictionaries and HashSets are treated specially, because it is cheaper to iterate over their keys and values
+    /// compared to traverse their internal data structures.
     /// </summary>
     private static void CollectObjectGraphObjects(this object obj, HashSet<object> objects) {
       if (obj == null || objects.Contains(obj)) return;
-      if (obj is Delegate || obj is EventHandler) return;
-      if (obj is Pointer) return;
       Type type = obj.GetType();
-      if (type.IsSubclassOfRawGeneric(typeof(EventHandler<>))) return;
-      if (type.IsPrimitive || type == typeof(string) || type == typeof(decimal)) return;
-      if (type.HasElementType) {
-        Type elementType = type.GetElementType();
-        if (elementType.IsPrimitive || elementType == typeof(string) || elementType == typeof(decimal)) return;
-        //TODO check all types
-      }
+      if (ExcludeType(type)) return;
+      if (type.HasElementType && ExcludeType(type.GetElementType())) return;
 
       objects.Add(obj);
 
-      //if (typeof(Type).IsInstanceOfType(obj)) return; // avoid infinite recursion
-      //if (type.IsSubclassOfRawGeneric(typeof(ThreadLocal<>))) return; // avoid stack overflow when the field `ConcurrentStack<int> s_availableIndices` grows large
-
-      // performance critical to handle dictionaries in a special way
-      var dictionary = obj as IDictionary;
-      if (dictionary != null) {
+      if (type.IsSubclassOfRawGeneric(typeof(ThreadLocal<>))) return; // avoid stack overflow when the field `ConcurrentStack<int> s_availableIndices` too grows large
+      
+      // performance critical to handle dictionaries, hashsets and hashtables in a special way
+      if (type.IsSubclassOfRawGeneric(typeof(Dictionary<,>)) || 
+          type.IsSubclassOfRawGeneric(typeof(SortedDictionary<,>)) || 
+          type.IsSubclassOfRawGeneric(typeof(SortedList<,>)) ||
+          obj is SortedList || 
+          obj is OrderedDictionary || 
+          obj is ListDictionary || 
+          obj is Hashtable) {        
+        var dictionary = obj as IDictionary;
         foreach (object value in dictionary.Keys)
           CollectObjectGraphObjects(value, objects);
@@ -69,7 +69,7 @@
           CollectObjectGraphObjects(value, objects);
         return;
-      } else if (type.IsArray) {
-        var array = obj as Array;
-        foreach (object value in array)
+      } else if (type.IsArray || type.IsSubclassOfRawGeneric(typeof(HashSet<>))) {
+        var enumerable = obj as IEnumerable;
+        foreach (var value in enumerable)
           CollectObjectGraphObjects(value, objects);
         return;
@@ -80,4 +80,12 @@
       }
     }
+
+    private static bool ExcludeType(Type type) {
+      return type.IsPrimitive ||
+             type == typeof(string) || 
+             type == typeof(decimal) ||
+             typeof(Delegate).IsAssignableFrom(type) || 
+             typeof(Pointer).IsAssignableFrom(type);
+    }
   }
 }
Index: trunk/sources/HeuristicLab/3.3/Tests/AlgorithmExtensions.cs
===================================================================
--- trunk/sources/HeuristicLab/3.3/Tests/AlgorithmExtensions.cs	(revision 6205)
+++ trunk/sources/HeuristicLab/3.3/Tests/AlgorithmExtensions.cs	(revision 6205)
@@ -0,0 +1,78 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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.Threading;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab_33.Tests {
+  public static class AlgorithmExtensions {
+    public static void StartSync(this IAlgorithm algorithm, CancellationToken cancellationToken) {
+      var executor = new AlgorithmExecutor(algorithm, cancellationToken);
+      executor.StartSync();
+    }
+  }
+
+  /// <summary>
+  /// Can execute an algorithm synchronously
+  /// </summary>
+  internal class AlgorithmExecutor {
+    private IAlgorithm algorithm;
+    private AutoResetEvent waitHandle = new AutoResetEvent(false);
+    private CancellationToken cancellationToken;
+
+    public AlgorithmExecutor(IAlgorithm algorithm, CancellationToken cancellationToken) {
+      this.algorithm = algorithm;
+      this.cancellationToken = cancellationToken;
+    }
+
+    public void StartSync() {
+      algorithm.Stopped += new EventHandler(algorithm_Stopped);
+      algorithm.Paused += new EventHandler(algorithm_Paused);
+
+      using (CancellationTokenRegistration registration = cancellationToken.Register(new Action(cancellationToken_Canceled))) {
+        algorithm.Start();
+        waitHandle.WaitOne();
+        waitHandle.Dispose();
+      }
+
+      algorithm.Stopped -= new EventHandler(algorithm_Stopped);
+      algorithm.Paused -= new EventHandler(algorithm_Paused);
+      if (algorithm.ExecutionState == ExecutionState.Started) {
+        algorithm.Pause();
+      }
+      cancellationToken.ThrowIfCancellationRequested();
+    }
+
+    private void algorithm_Paused(object sender, EventArgs e) {
+      waitHandle.Set();
+    }
+
+    private void algorithm_Stopped(object sender, EventArgs e) {
+      waitHandle.Set();
+    }
+
+    private void cancellationToken_Canceled() {
+      waitHandle.Set();
+    }
+  }
+}
Index: trunk/sources/HeuristicLab/3.3/Tests/CollectObjectGraphTest.cs
===================================================================
--- trunk/sources/HeuristicLab/3.3/Tests/CollectObjectGraphTest.cs	(revision 6201)
+++ trunk/sources/HeuristicLab/3.3/Tests/CollectObjectGraphTest.cs	(revision 6205)
@@ -24,7 +24,12 @@
 using System.Diagnostics;
 using System.Linq;
+using System.Threading;
 using HeuristicLab.Algorithms.GeneticAlgorithm;
 using HeuristicLab.Common;
+using HeuristicLab.Optimization;
 using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.TestFunctions;
+using HeuristicLab.Random;
+using HeuristicLab.SequentialEngine;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
@@ -82,4 +87,28 @@
       TestContext.WriteLine("");
     }
+
+    [TestMethod]
+    public void AlgorithmExecutions() {
+      var random = new MersenneTwister(0);
+      var algs = new List<IAlgorithm>();
+
+      Stopwatch sw = new Stopwatch();
+      for (int i = 0; i < 100; i++) {
+        GeneticAlgorithm ga = new GeneticAlgorithm();
+        ga.PopulationSize.Value = 5;
+        ga.MaximumGenerations.Value = 5;
+        ga.Engine = new SequentialEngine();
+        ga.Problem = new SingleObjectiveTestFunctionProblem();
+
+        sw.Start();
+        algs.Add(ga);
+
+        var cancellationTokenSource = new CancellationTokenSource();
+        ga.StartSync(cancellationTokenSource.Token);
+        sw.Stop();
+        TestContext.WriteLine("{0}: {1} ", i, sw.Elapsed);
+        sw.Reset();
+      }
+    }
   }
 }
Index: trunk/sources/HeuristicLab/3.3/Tests/HeuristicLab-3.3.Tests.csproj
===================================================================
--- trunk/sources/HeuristicLab/3.3/Tests/HeuristicLab-3.3.Tests.csproj	(revision 6201)
+++ trunk/sources/HeuristicLab/3.3/Tests/HeuristicLab-3.3.Tests.csproj	(revision 6205)
@@ -122,4 +122,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AlgorithmExtensions.cs" />
     <Compile Include="CloningConstructorTest.cs" />
     <Compile Include="CollectObjectGraphTest.cs" />
@@ -559,4 +560,7 @@
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
+    <None Include="GA_SymbReg2.hl">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
