Index: /branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
===================================================================
--- /branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs	(revision 6434)
+++ /branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs	(revision 6435)
@@ -38,5 +38,4 @@
   public class HiveEngine : Engine {
     private static object locker = new object();
-    private static object logLocker = new object();
     private CancellationToken cancellationToken;
     private bool firstRun = true;
@@ -74,5 +73,5 @@
     }
 
-    // [Storable] -> HiveExperiment can't be storable, so RefreshableHiveExperiment can't be stored
+    // HiveExperiment can't be storable, so RefreshableHiveExperiment can't be stored. But as previous runs are only informative it does not matter (only execution time on hive will be wrong because of that -> Todo)
     private ItemCollection<RefreshableHiveExperiment> hiveExperiments = new ItemCollection<RefreshableHiveExperiment>();
     public ItemCollection<RefreshableHiveExperiment> HiveExperiments {
@@ -97,4 +96,5 @@
       ResourceNames = "HEAL";
       Priority = 0;
+      this.log = new ThreadSafeLog(this.log);
     }
 
@@ -108,5 +108,5 @@
       this.executionTimeOnHive = original.executionTimeOnHive;
       this.IsPrivileged = original.IsPrivileged;
-      // this.hiveExperiments = cloner.Clone(original.hiveExperiments); do not clone hiveExperiments - otherwise they would be sent with every job
+      // do not clone hiveExperiments - otherwise they would be sent with every job
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -150,41 +150,7 @@
 
         next = executionStack.Pop();
-        //bool isOpCollection = next is OperationCollection;
-        //int collCount = isOpCollection ? ((OperationCollection)next).Count : 0;
-        //string opName = !isOpCollection ? ((IAtomicOperation)next).Operator.Name : "OpCollection";
-
         if (next is OperationCollection) {
           coll = (OperationCollection)next;
 
-          //bool isPMOEvaluator = coll.Count > 0 && coll.First() is HeuristicLab.Core.ExecutionContext && ((HeuristicLab.Core.ExecutionContext)coll.First()).Operator.GetType().Name == "PMOEvaluator";
-          //bool isAlgorithmEvaluator = coll.Count > 0 && coll.First() is HeuristicLab.Core.ExecutionContext && ((HeuristicLab.Core.ExecutionContext)coll.First()).Operator.GetType().Name == "AlgorithmEvaluator";
-
-          //if (coll.Parallel && isPMOEvaluator) {
-          //  Task[] tasks = new Task[coll.Count];
-          //  Stack<IOperation>[] stacks = new Stack<IOperation>[coll.Count];
-          //  for (int i = 0; i < coll.Count; i++) {
-          //    stacks[i] = new Stack<IOperation>();
-          //    stacks[i].Push(coll[i]);
-          //    tasks[i] = Task.Factory.StartNew(Run, stacks[i], cancellationToken);
-          //  }
-          //  try {
-          //    Task.WaitAll(tasks);
-          //  }
-          //  catch (AggregateException ex) {
-          //    OperationCollection remaining = new OperationCollection() { Parallel = true };
-          //    for (int i = 0; i < stacks.Length; i++) {
-          //      if (stacks[i].Count == 1)
-          //        remaining.Add(stacks[i].Pop());
-          //      if (stacks[i].Count > 1) {
-          //        OperationCollection ops = new OperationCollection();
-          //        while (stacks[i].Count > 0)
-          //          ops.Add(stacks[i].Pop());
-          //        remaining.Add(ops);
-          //      }
-          //    }
-          //    if (remaining.Count > 0) executionStack.Push(remaining);
-          //    throw ex;
-          //  }
-          //} else if (coll.Parallel) {
           if (coll.Parallel) {
             try {
@@ -230,5 +196,5 @@
 
           if (operation.Operator.Breakpoint) {
-            LogMessage(string.Format("Breakpoint: {0}", operation.Operator.Name != string.Empty ? operation.Operator.Name : operation.Operator.ItemName));
+            log.LogMessage(string.Format("Breakpoint: {0}", operation.Operator.Name != string.Empty ? operation.Operator.Name : operation.Operator.ItemName));
             Pause();
           }
@@ -273,5 +239,5 @@
     /// <param name="jobs"></param>
     private IScope[] ExecuteOnHive(RefreshableHiveExperiment refreshableHiveExperiment, EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {
-      LogMessage(string.Format("Executing {0} operations on the hive.", jobs.Length));
+      log.LogMessage(string.Format("Executing {0} operations on the hive.", jobs.Length));
       IScope[] scopes = new Scope[jobs.Length];
       object locker = new object();
@@ -290,5 +256,5 @@
             random.Reset(random.Next());
         }
-        HiveClient.StartExperiment((e) => { LogException(e); }, refreshableHiveExperiment);
+        HiveClient.StartExperiment((e) => { log.LogException(e); }, refreshableHiveExperiment);
 
         // do polling until experiment is finished and all jobs are downloaded
@@ -298,5 +264,5 @@
           cancellationToken.ThrowIfCancellationRequested();
         }
-        LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableHiveExperiment.ToString(), refreshableHiveExperiment.HiveExperiment.ExecutionTime));
+        log.LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableHiveExperiment.ToString(), refreshableHiveExperiment.HiveExperiment.ExecutionTime));
 
         var failedJobs = hiveExperiment.HiveJobs.Where(x => x.Job.State == JobState.Failed);
@@ -317,5 +283,5 @@
       }
       catch (Exception e) {
-        LogException(e);
+        log.LogException(e);
         throw e;
       }
@@ -372,40 +338,4 @@
       });
     }
-
-    /// <summary>
-    /// Threadsafe message logging
-    /// </summary>
-    private void LogMessage(string message) {
-      lock (logLocker) {
-        Log.LogMessage(message);
-      }
-    }
-
-    /// <summary>
-    /// Threadsafe exception logging
-    /// </summary>
-    private void LogException(Exception exception) {
-      lock (logLocker) {
-        Log.LogException(exception);
-      }
-    }
-
-    // testfunction:
-    //private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {
-    //  IScope[] scopes = new Scope[jobs.Length];
-    //  for (int i = 0; i < jobs.Length; i++) {
-    //    var serialized = PersistenceUtil.Serialize(jobs[i]);
-    //    var deserialized = PersistenceUtil.Deserialize<IJob>(serialized);
-    //    deserialized.Start();
-    //    while (deserialized.ExecutionState != ExecutionState.Stopped) {
-    //      Thread.Sleep(100);
-    //    }
-    //    var serialized2 = PersistenceUtil.Serialize(deserialized);
-    //    var deserialized2 = PersistenceUtil.Deserialize<EngineJob>(serialized2);
-    //    var newScope = ((IAtomicOperation)deserialized2.InitialOperation).Scope;
-    //    scopes[i] = newScope;
-    //  }
-    //  return scopes;
-    //}
   }
 }
