Index: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
===================================================================
--- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs	(revision 6107)
+++ branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs	(revision 6110)
@@ -44,5 +44,5 @@
     public static ILog Log { get; set; }
 
-    private Dictionary<Guid, Executor> engines = new Dictionary<Guid, Executor>();
+    private Dictionary<Guid, Executor> executors = new Dictionary<Guid, Executor>();
     private Dictionary<Guid, AppDomain> appDomains = new Dictionary<Guid, AppDomain>();
     private Dictionary<Guid, Job> jobs = new Dictionary<Guid, Job>();
@@ -55,6 +55,6 @@
     private ServiceHost slaveComm;
 
-    public Dictionary<Guid, Executor> ExecutionEngines {
-      get { return engines; }
+    public Dictionary<Guid, Executor> Executors {
+      get { return executors; }
     }
 
@@ -162,5 +162,5 @@
               Job job = wcfService.GetJob(jobId);
               if (job == null) throw new JobNotFoundException(jobId);
-              lock (engines) {
+              lock (executors) {
                 if (!jobs.ContainsKey(job.Id)) {
                   jobs.Add(job.Id, job);
@@ -177,6 +177,4 @@
               // handle exception of task
               clientCom.LogMessage(t.Exception.ToString());
-              wcfService.UpdateJobState(container.JobId, JobState.Failed, t.Exception.ToString());
-              SlaveStatusInfo.JobsAborted++;
             }, TaskContinuationOptions.OnlyOnFaulted);
             break;
@@ -225,11 +223,11 @@
 
         if (job != null) {
-          engines[job.Id].Pause();
-          JobData sJob = engines[job.Id].GetPausedJob();
-          job.ExecutionTime = engines[job.Id].ExecutionTime;
+          executors[job.Id].Pause();
+          JobData sJob = executors[job.Id].GetPausedJob();
+          job.ExecutionTime = executors[job.Id].ExecutionTime;
 
           try {
-            if (engines[job.Id].CurrentException != string.Empty) {
-              wcfService.UpdateJobState(job.Id, JobState.Failed, engines[job.Id].CurrentException);
+            if (executors[job.Id].CurrentException != string.Empty) {
+              wcfService.UpdateJobState(job.Id, JobState.Failed, executors[job.Id].CurrentException);
               SlaveStatusInfo.JobsAborted++;
             } else {
@@ -256,12 +254,12 @@
 
         if (job != null) {
-          engines[job.Id].Stop();
-          JobData sJob = engines[job.Id].GetFinishedJob();
-          job.ExecutionTime = engines[job.Id].ExecutionTime;
+          executors[job.Id].Stop();
+          JobData sJob = executors[job.Id].GetFinishedJob();
+          job.ExecutionTime = executors[job.Id].ExecutionTime;
 
 
           try {
-            if (engines[job.Id].CurrentException != string.Empty) {
-              wcfService.UpdateJobState(job.Id, JobState.Failed, engines[job.Id].CurrentException);
+            if (executors[job.Id].CurrentException != string.Empty) {
+              wcfService.UpdateJobState(job.Id, JobState.Failed, executors[job.Id].CurrentException);
             }
             SlaveStatusInfo.JobsAborted++;
@@ -350,6 +348,6 @@
 
 
-      lock (engines) {
-        clientCom.LogMessage("engines locked");
+      lock (executors) {
+        clientCom.LogMessage("executors locked");
         foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) {
           clientCom.LogMessage("Shutting down Appdomain for " + kvp.Key);
@@ -411,6 +409,6 @@
       try {
         clientCom.LogMessage("Getting the finished job with id: " + jobId);
-        if (!engines.ContainsKey(jobId)) {
-          clientCom.LogMessage("Engine doesn't exist");
+        if (!executors.ContainsKey(jobId)) {
+          clientCom.LogMessage("Executor doesn't exist");
           return;
         }
@@ -420,7 +418,7 @@
         }
         Job cJob = jobs[jobId];
-        cJob.ExecutionTime = engines[jobId].ExecutionTime;
-
-        if (engines[jobId].Aborted) {
+        cJob.ExecutionTime = executors[jobId].ExecutionTime;
+
+        if (executors[jobId].Aborted) {
           SlaveStatusInfo.JobsAborted++;
         } else {
@@ -428,9 +426,9 @@
         }
 
-        if (engines[jobId].CurrentException != string.Empty) {
-          wcfService.UpdateJobState(jobId, JobState.Failed, engines[jobId].CurrentException);
-        }
-
-        JobData sJob = engines[jobId].GetFinishedJob();
+        if (executors[jobId].CurrentException != string.Empty) {
+          wcfService.UpdateJobState(jobId, JobState.Failed, executors[jobId].CurrentException);
+        }
+
+        JobData sJob = executors[jobId].GetFinishedJob();
         try {
           clientCom.LogMessage("Sending the finished job with id: " + jobId);
@@ -450,5 +448,5 @@
     }
 
-    private static object locker = new object();
+    private static object startInAppDomainLocker = new object();
 
     /// <summary>
@@ -459,6 +457,6 @@
       clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());
 
-      lock (locker) {
-        if (engines.ContainsKey(myJob.Id)) {
+      lock (startInAppDomainLocker) {
+        if (executors.ContainsKey(myJob.Id)) {
           clientCom.LogMessage("Job with key " + myJob.Id + " already exists. Job will be ignored.");
           return;
@@ -476,8 +474,5 @@
         catch (Exception exception) {
           clientCom.LogMessage(string.Format("Copying plugins for job {0} failed: {1}", myJob.Id, exception));
-          wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString());
-          SlaveStatusInfo.JobsAborted++;
-
-          lock (engines) {
+          lock (executors) {
             if (jobs.ContainsKey(myJob.Id)) {
               jobs.Remove(myJob.Id);
@@ -490,28 +485,22 @@
             AppDomain appDomain = HeuristicLab.PluginInfrastructure.Sandboxing.SandboxManager.CreateAndInitSandbox(myJob.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName));
             appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException);
-            Executor engine;
-            lock (engines) {
-              appDomains.Add(myJob.Id, appDomain);
-              clientCom.LogMessage("Creating AppDomain");
-              engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName);
-              clientCom.LogMessage("Created AppDomain");
-              engine.JobId = myJob.Id;
-              engine.Core = this;
-              clientCom.LogMessage("Starting Engine for job " + myJob.Id);
-              engines.Add(myJob.Id, engine);
+            Executor executor;
+            appDomains.Add(myJob.Id, appDomain);
+            clientCom.LogMessage("Creating AppDomain");
+            executor = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName);
+            clientCom.LogMessage("Created AppDomain");
+            executor.JobId = myJob.Id;
+            executor.Core = this;
+            clientCom.LogMessage("Starting Executor for job " + myJob.Id);
+
+            executor.Start(jobData.Data);
+            
+            lock (executors) {
+              executors.Add(myJob.Id, executor);
             }
-            engine.Start(jobData.Data);
           }
           catch (Exception exception) {
             clientCom.LogMessage("Creating the Appdomain and loading the job failed for job " + myJob.Id);
             clientCom.LogMessage("Error thrown is: " + exception.ToString());
-
-            if (engines.ContainsKey(myJob.Id) && engines[myJob.Id].CurrentException != string.Empty) {
-              wcfService.UpdateJobState(myJob.Id, JobState.Failed, engines[myJob.Id].CurrentException);
-            } else {
-              wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString());
-            }
-            SlaveStatusInfo.JobsAborted++;
-
             KillAppDomain(myJob.Id);
           }
@@ -557,9 +546,9 @@
 
       clientCom.LogMessage("Shutting down Appdomain for Job " + id);
-      lock (engines) {
+      lock (executors) {
         try {
-          if (engines.ContainsKey(id)) {
-            engines[id].Dispose();
-            engines.Remove(id);
+          if (executors.ContainsKey(id)) {
+            executors[id].Dispose();
+            executors.Remove(id);
           }
 
@@ -597,4 +586,8 @@
       clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());
     }
+
+    public override object InitializeLifetimeService() {
+      return null; // avoid destruction of proxy object after 5 minutes
+    }
   }
 }
