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 5621)
+++ branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs	(revision 5636)
@@ -140,8 +140,8 @@
         switch (container.Message) {
           case MessageContainer.MessageType.CalculateJob:
-            Job myJob = wcfService.GetJob(container.JobId);
-            //TODO: handle in own thread!!
-            JobData jobData = wcfService.GetJobData(myJob.Id);
-            StartJobInAppDomain(myJob, jobData);
+            Job job = wcfService.GetJob(container.JobId);
+            JobData jobData = wcfService.GetJobData(job.Id);
+            job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null);
+            StartJobInAppDomain(job, jobData);
             break;
           case MessageContainer.MessageType.ShutdownSlave:
@@ -181,6 +181,6 @@
     }
 
-    private void DoPauseJob(Guid guid) {
-      Job job = Jobs[guid];
+    private void DoPauseJob(Guid jobId) {
+      Job job = Jobs[jobId];
 
       if (job != null) {
@@ -192,5 +192,5 @@
         try {
           ClientCom.LogMessage("Sending the paused job with id: " + job.Id);
-          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id);
+          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused);
           SlaveStatusInfo.JobsProcessed++;    //TODO: count or not count, thats the question
         }
@@ -215,5 +215,5 @@
         try {
           ClientCom.LogMessage("Sending the stoppped job with id: " + job.Id);
-          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id);
+          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused);
           SlaveStatusInfo.JobsProcessed++;    //TODO: count or not count, thats the question
         }
@@ -347,7 +347,6 @@
       } else {
         Job job = Jobs[data.JobId];
-        job.SetState(JobState.Transferring);
-        wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id);
-        job.SetState(JobState.Waiting); // todo: what if it was a ResumeOnChildJobsFinished job before? maybe look into StateLog
+        wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused);
+        job.SetState(JobState.Waiting);
         wcfService.UpdateJob(job);
       }
@@ -373,5 +372,4 @@
         }
         Job cJob = jobs[jobId];
-        cJob.State = JobState.Finished; // TODO: what if failed?
         cJob.ExecutionTime = engines[jobId].ExecutionTime;
 
@@ -382,5 +380,5 @@
         try {
           ClientCom.LogMessage("Sending the finished job with id: " + jobId);
-          wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id);
+          wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Finished);
           SlaveStatusInfo.JobsProcessed++;
         }
Index: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs
===================================================================
--- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs	(revision 5621)
+++ branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs	(revision 5636)
@@ -49,4 +49,77 @@
     public NetworkEnum.WcfConnState ConnState { get; private set; }
 
+    private WcfService() {
+      ConnState = NetworkEnum.WcfConnState.Disconnected;
+    }
+
+    #region Job Methods
+    public Job GetJob(Guid jobId) {
+      return CallHiveService(s => s.GetJob(jobId));
+    }
+
+    public void UpdateJob(Job job) {
+      CallHiveService(s => s.UpdateJob(job));
+    }
+
+    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
+      return CallHiveService(s => s.AddChildJob(parentJobId, job, jobData));
+    }
+
+    public IEnumerable<JobData> GetChildJobs(Guid? parentJobId) {
+      return CallHiveService(service => {
+        IEnumerable<LightweightJob> msg = service.GetLightweightChildJobs(parentJobId, false, false);
+
+        List<JobData> jobs = new List<JobData>();
+        foreach (LightweightJob ljob in msg)
+          jobs.Add(service.GetJobData(ljob.Id));
+
+        return jobs;
+      });
+    }
+
+    public void DeleteChildJobs(Guid jobId) {
+      CallHiveService(s => s.DeleteChildJobs(jobId));
+    }
+    #endregion
+
+    #region JobData Methods
+    public JobData GetJobData(Guid jobId) {
+      return CallHiveService(s => s.GetJobData(jobId));
+    }
+
+    /// <summary>
+    /// Uploads the JobData and sets a new jobState (while correctly setting Transferring state)
+    /// </summary>
+    public void UpdateJobData(Job job, JobData jobData, Guid slaveId, JobState state) {
+      CallHiveService(service => {
+        service.UpdateJob(job);
+        job = service.UpdateJobState(job.Id, JobState.Transferring, slaveId, null, null);
+        service.UpdateJobData(job, jobData);
+        service.UpdateJobState(job.Id, state, slaveId, null, null);
+      });
+    }
+
+    public Job UpdateJobState(Guid jobId, JobState jobState, string exception) {
+      return CallHiveService(s => s.UpdateJobState(jobId, jobState, ConfigManager.GetUniqueMachineId(), null, exception));
+    }
+    #endregion
+
+    #region Heartbeat Methods
+    public List<MessageContainer> SendHeartbeat(Heartbeat heartbeat) {
+      return CallHiveService(s => s.Heartbeat(heartbeat));
+    }
+    #endregion
+
+    #region Plugin Methods
+    public IEnumerable<Plugin> GetPlugins() {
+      return CallHiveService(s => s.GetPlugins());
+    }
+
+    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
+      return CallHiveService(s => s.GetPluginDatas(pluginIds));
+    }
+    #endregion
+
+    #region Events
     public event EventHandler Connected;
     private void OnConnected() {
@@ -60,12 +133,7 @@
       if (handler != null) handler(this, new EventArgs<Exception>(e));
     }
+    #endregion
 
-    /// <summary>
-    /// Constructor
-    /// </summary>
-    private WcfService() {
-      ConnState = NetworkEnum.WcfConnState.Disconnected;
-    }
-
+    #region Helpers
     /// <summary>
     /// Connects with the Server, registers the events and fires the Connected (and quiet possibly the ConnectionRestored) Event.
@@ -99,70 +167,4 @@
     }
 
-    /// <summary>
-    /// Get a Job from the Server
-    /// </summary>
-    public Job GetJob(Guid jobId) {
-      return CallHiveService(s => s.GetJob(jobId));
-    }
-
-    public JobData GetJobData(Guid jobId) {
-      return CallHiveService(s => s.GetJobData(jobId));
-    }
-
-    public void UpdateJob(Job job) {
-      CallHiveService(s => s.UpdateJob(job));
-    }
-
-    /// <summary>
-    /// used on pause or if job finished to upload the job results
-    /// </summary>
-    /// <param name="job"></param>
-    /// <param name="jobData"></param>    
-    public void UpdateJobData(Job job, JobData jobData, Guid slaveId) {
-      CallHiveService(service => {
-        JobState before = job.State;
-        job.SetState(JobState.Transferring, slaveId, "");
-
-        service.UpdateJob(job);
-
-        service.UpdateJobData(job, jobData);
-
-        job.SetState(before, slaveId, "");
-        service.UpdateJob(job);
-      });
-    }
-
-    public List<MessageContainer> SendHeartbeat(Heartbeat heartbeat) {
-      return CallHiveService(s => s.Heartbeat(heartbeat));
-    }
-
-    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
-      return CallHiveService(s => s.GetPluginDatas(pluginIds));
-    }
-
-    public IEnumerable<Plugin> GetPlugins() {
-      return CallHiveService(s => s.GetPlugins());
-    }
-
-    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
-      return CallHiveService(s => s.AddChildJob(parentJobId, job, jobData));
-    }
-
-    public IEnumerable<JobData> GetChildJobs(Guid? parentJobId) {
-      return CallHiveService(service => {
-        IEnumerable<LightweightJob> msg = service.GetLightweightChildJobs(parentJobId, false, false);
-
-        List<JobData> jobs = new List<JobData>();
-        foreach (LightweightJob ljob in msg)
-          jobs.Add(service.GetJobData(ljob.Id));
-
-        return jobs;
-      });
-    }
-
-    public void DeleteChildJobs(Guid jobId) {
-      CallHiveService(s => s.DeleteChildJobs(jobId));
-    }
-
     public void CallHiveService(Action<IHiveService> call) {
       try {
@@ -183,4 +185,5 @@
       }
     }
+    #endregion
   }
 }
