Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs	(revision 12858)
@@ -55,20 +55,21 @@
 
     public void RunCleanup() {
+      var pm = PersistenceManager;
       while (!stop) {
         try {
           LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup.");
           bool cleanup = false;
-          using (var pm = PersistenceManager) {
-            var lifecycleDao = pm.LifecycleDao;
-            pm.UseTransaction(() => {
-              var lifecycle = lifecycleDao.GetLastLifecycle();
-              if (lifecycle == null
-                  || DateTime.Now - lifecycle.LastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) {
-                lifecycleDao.UpdateLifecycle();
-                cleanup = true;
-              }
-              pm.SubmitChanges();
-            }, true);
-          }
+
+          var lifecycleDao = pm.LifecycleDao;
+          pm.UseTransaction(() => {
+            var lifecycle = lifecycleDao.GetLastLifecycle();
+            if (lifecycle == null
+                || DateTime.Now - lifecycle.LastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) {
+              lifecycleDao.UpdateLifecycle();
+              cleanup = true;
+            }
+            pm.SubmitChanges();
+          }, true);
+
           if (cleanup) {
             EventManager.Cleanup();
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs	(revision 12858)
@@ -52,34 +52,31 @@
     public void AuthorizeForTask(Guid taskId, DT.Permission requiredPermission) {
       if (ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
-      using (var pm = PersistenceManager) {
-        var taskDao = pm.TaskDao;
-        pm.UseTransaction(() => {
-          var task = taskDao.GetById(taskId);
-          if (task == null) throw new SecurityException(NOT_AUTHORIZED);
-          AuthorizeJob(pm, task.JobId, requiredPermission);
-        });
-      }
+      var pm = PersistenceManager;
+      var taskDao = pm.TaskDao;
+      pm.UseTransaction(() => {
+        var task = taskDao.GetById(taskId);
+        if (task == null) throw new SecurityException(NOT_AUTHORIZED);
+        AuthorizeJob(pm, task.JobId, requiredPermission);
+      });
     }
 
     public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) {
-      using (var pm = PersistenceManager) {
-        pm.UseTransaction(() => {
-          AuthorizeJob(pm, jobId, requiredPermission);
-        });
-      }
+      var pm = PersistenceManager;
+      pm.UseTransaction(() => {
+        AuthorizeJob(pm, jobId, requiredPermission);
+      });
     }
 
     public void AuthorizeForResourceAdministration(Guid resourceId) {
-      using (var pm = PersistenceManager) {
-        var resourceDao = pm.ResourceDao;
-        pm.UseTransaction(() => {
-          var resource = resourceDao.GetById(resourceId);
-          if (resource == null) throw new SecurityException(NOT_AUTHORIZED);
-          if (resource.OwnerUserId != UserManager.CurrentUserId
-              && !RoleVerifier.IsInRole(HiveRoles.Administrator)) {
-            throw new SecurityException(NOT_AUTHORIZED);
-          }
-        });
-      }
+      var pm = PersistenceManager;
+      var resourceDao = pm.ResourceDao;
+      pm.UseTransaction(() => {
+        var resource = resourceDao.GetById(resourceId);
+        if (resource == null) throw new SecurityException(NOT_AUTHORIZED);
+        if (resource.OwnerUserId != UserManager.CurrentUserId
+            && !RoleVerifier.IsInRole(HiveRoles.Administrator)) {
+          throw new SecurityException(NOT_AUTHORIZED);
+        }
+      });
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewEventManager.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewEventManager.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewEventManager.cs	(revision 12858)
@@ -31,26 +31,19 @@
       get { return ServiceLocator.Instance.PersistenceManager; }
     }
-    private IAuthorizationManager AuthorizationManager {
-      get { return ServiceLocator.Instance.AuthorizationManager; }
-    }
-    private ILogger Log {
-      get { return LogFactory.GetLogger(this.GetType().Namespace); }
-    }
 
     public void Cleanup() {
-      using (var pm = PersistenceManager) {
-        // same transactions as the old EventManager
-        pm.UseTransaction(() => {
-          SetTimeoutSlavesOffline(pm);
-          SetTimeoutTasksWaiting(pm);
-          DeleteObsoleteSlaves(pm);
-          pm.SubmitChanges();
-        });
+      var pm = PersistenceManager;
+      // same transactions as the old EventManager
+      pm.UseTransaction(() => {
+        SetTimeoutSlavesOffline(pm);
+        SetTimeoutTasksWaiting(pm);
+        DeleteObsoleteSlaves(pm);
+        pm.SubmitChanges();
+      });
 
-        pm.UseTransaction(() => {
-          FinishParentTasks(pm);
-          pm.SubmitChanges();
-        });
-      }
+      pm.UseTransaction(() => {
+        FinishParentTasks(pm);
+        pm.SubmitChanges();
+      });
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewHeartbeatManager.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewHeartbeatManager.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Manager/NewHeartbeatManager.cs	(revision 12858)
@@ -47,67 +47,66 @@
     public List<MessageContainer> ProcessHeartbeat(Heartbeat heartbeat) {
       List<MessageContainer> actions = new List<MessageContainer>();
-      using (var pm = PersistenceManager) {
-        var slaveDao = pm.SlaveDao;
-        var taskDao = pm.TaskDao;
-        var slave = pm.UseTransaction(() => slaveDao.GetById(heartbeat.SlaveId));
-        if (slave == null) {
-          actions.Add(new MessageContainer(MessageContainer.MessageType.SayHello));
-        } else {
-          if (heartbeat.HbInterval != slave.HbInterval) {
-            actions.Add(new MessageContainer(MessageContainer.MessageType.NewHBInterval));
-          }
-          if (slaveDao.SlaveHasToShutdownComputer(slave.ResourceId)) {
-            actions.Add(new MessageContainer(MessageContainer.MessageType.ShutdownComputer));
-          }
-          // update slave data  
-          slave.FreeCores = heartbeat.FreeCores;
-          slave.FreeMemory = heartbeat.FreeMemory;
-          slave.CpuUtilization = heartbeat.CpuUtilization;
-          slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0)
-            ? DA.SlaveState.Calculating
-            : DA.SlaveState.Idle;
-          slave.LastHeartbeat = DateTime.Now;
-          pm.UseTransaction(() => {
-            slave.IsAllowedToCalculate = slaveDao.SlaveIsAllowedToCalculate(slave.ResourceId);
-            pm.SubmitChanges();
-          });
-
-          // update task data
-          actions.AddRange(UpdateTasks(pm, heartbeat, slave.IsAllowedToCalculate));
-
-          // assign new task
-          if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
-            bool mutexAquired = false;
-            var mutex = new Mutex(false, MutexName);
-            try {
-              mutexAquired = mutex.WaitOne(Properties.Settings.Default.SchedulingPatience);
-              if (mutexAquired) {
-                var waitingTasks = pm.UseTransaction(() => taskDao.GetWaitingTasks(slave)
-                    .Select(x => new TaskInfoForScheduler {
-                      TaskId = x.TaskId,
-                      JobId = x.JobId,
-                      Priority = x.Priority
-                    })
-                    .ToList()
-                );
-                var availableTasks = TaskScheduler.Schedule(waitingTasks);
-                if (availableTasks.Any()) {
-                  var task = availableTasks.First();
-                  AssignTask(pm, slave, task.TaskId);
-                  actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateTask, task.TaskId));
-                }
-              } else {
-                LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling could not be aquired.");
+      var pm = PersistenceManager;
+      var slaveDao = pm.SlaveDao;
+      var taskDao = pm.TaskDao;
+      var slave = pm.UseTransaction(() => slaveDao.GetById(heartbeat.SlaveId));
+      if (slave == null) {
+        actions.Add(new MessageContainer(MessageContainer.MessageType.SayHello));
+      } else {
+        if (heartbeat.HbInterval != slave.HbInterval) {
+          actions.Add(new MessageContainer(MessageContainer.MessageType.NewHBInterval));
+        }
+        if (slaveDao.SlaveHasToShutdownComputer(slave.ResourceId)) {
+          actions.Add(new MessageContainer(MessageContainer.MessageType.ShutdownComputer));
+        }
+        // update slave data  
+        slave.FreeCores = heartbeat.FreeCores;
+        slave.FreeMemory = heartbeat.FreeMemory;
+        slave.CpuUtilization = heartbeat.CpuUtilization;
+        slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0)
+          ? DA.SlaveState.Calculating
+          : DA.SlaveState.Idle;
+        slave.LastHeartbeat = DateTime.Now;
+        pm.UseTransaction(() => {
+          slave.IsAllowedToCalculate = slaveDao.SlaveIsAllowedToCalculate(slave.ResourceId);
+          pm.SubmitChanges();
+        });
+
+        // update task data
+        actions.AddRange(UpdateTasks(pm, heartbeat, slave.IsAllowedToCalculate));
+
+        // assign new task
+        if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
+          bool mutexAquired = false;
+          var mutex = new Mutex(false, MutexName);
+          try {
+            mutexAquired = mutex.WaitOne(Properties.Settings.Default.SchedulingPatience);
+            if (mutexAquired) {
+              var waitingTasks = pm.UseTransaction(() => taskDao.GetWaitingTasks(slave)
+                  .Select(x => new TaskInfoForScheduler {
+                    TaskId = x.TaskId,
+                    JobId = x.JobId,
+                    Priority = x.Priority
+                  })
+                  .ToList()
+              );
+              var availableTasks = TaskScheduler.Schedule(waitingTasks).ToArray();
+              if (availableTasks.Any()) {
+                var task = availableTasks.First();
+                AssignTask(pm, slave, task.TaskId);
+                actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateTask, task.TaskId));
               }
+            } else {
+              LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling could not be aquired.");
             }
-            catch (AbandonedMutexException) {
-              LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling has been abandoned.");
-            }
-            catch (Exception ex) {
-              LogFactory.GetLogger(this.GetType().Namespace).Log(string.Format("HeartbeatManager threw an exception in ProcessHeartbeat: {0}", ex));
-            }
-            finally {
-              if (mutexAquired) mutex.ReleaseMutex();
-            }
+          }
+          catch (AbandonedMutexException) {
+            LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling has been abandoned.");
+          }
+          catch (Exception ex) {
+            LogFactory.GetLogger(this.GetType().Namespace).Log(string.Format("HeartbeatManager threw an exception in ProcessHeartbeat: {0}", ex));
+          }
+          finally {
+            if (mutexAquired) mutex.ReleaseMutex();
           }
         }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Scheduler/NewRoundRobinTaskScheduler.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Scheduler/NewRoundRobinTaskScheduler.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Scheduler/NewRoundRobinTaskScheduler.cs	(revision 12858)
@@ -35,63 +35,63 @@
       if (!tasks.Any()) return Enumerable.Empty<TaskInfoForScheduler>();
 
-      using (var pm = PersistenceManager) {
-        var userPriorityDao = pm.UserPriorityDao;
-        var jobDao = pm.JobDao;
+      var pm = PersistenceManager;
+      var userPriorityDao = pm.UserPriorityDao;
+      var jobDao = pm.JobDao;
 
-        var userPriorities = pm.UseTransaction(() => userPriorityDao.GetAll()
-          .OrderBy(x => x.DateEnqueued)
-          .ToArray()
-        );
+      var userPriorities = pm.UseTransaction(() => userPriorityDao.GetAll()
+        .OrderBy(x => x.DateEnqueued)
+        .ToArray()
+      );
 
-        var userIds = userPriorities.Select(x => x.UserId).ToList();
-        var jobs = pm.UseTransaction(() => {
-          return jobDao.GetAll()
-            .Where(x => userIds.Contains(x.OwnerUserId))
-            .Select(x => new {
-              Id = x.JobId,
-              DateCreated = x.DateCreated,
-              OwnerUserId = x.OwnerUserId
-            })
-            .ToList();
-        });
+      var userIds = userPriorities.Select(x => x.UserId).ToList();
+      var jobs = pm.UseTransaction(() => {
+        return jobDao.GetAll()
+          .Where(x => userIds.Contains(x.OwnerUserId))
+          .Select(x => new {
+            Id = x.JobId,
+            DateCreated = x.DateCreated,
+            OwnerUserId = x.OwnerUserId
+          })
+          .ToList();
+      });
 
-        var taskJobRelations = tasks.Join(jobs,
-          task => task.JobId,
-          job => job.Id,
-          (task, job) => new { Task = task, JobInfo = job })
-          .OrderByDescending(x => x.Task.Priority)
-          .ToList();
+      var taskJobRelations = tasks.Join(jobs,
+        task => task.JobId,
+        job => job.Id,
+        (task, job) => new { Task = task, JobInfo = job })
+        .OrderByDescending(x => x.Task.Priority)
+        .ToList();
 
-        var scheduledTasks = new List<TaskInfoForScheduler>();
-        int priorityIndex = 0;
+      var scheduledTasks = new List<TaskInfoForScheduler>();
+      int priorityIndex = 0;
 
-        if (count == 0 || count > taskJobRelations.Count) count = taskJobRelations.Count;
+      if (count == 0 || count > taskJobRelations.Count) count = taskJobRelations.Count;
 
-        for (int i = 0; i < count; i++) {
-          var defaultEntry = taskJobRelations.First(); // search first task which is not included yet
-          var priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray(); // search for tasks with desired user priority
-          while (!priorityEntries.Any() && priorityIndex < userPriorities.Length - 1) {
+      for (int i = 0; i < count; i++) {
+        var defaultEntry = taskJobRelations.First(); // search first task which is not included yet
+        var priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray(); // search for tasks with desired user priority
+        while (!priorityEntries.Any() && priorityIndex < userPriorities.Length - 1) {
+          priorityIndex++;
+          priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray();
+        }
+        if (priorityEntries.Any()) { // tasks with desired user priority found
+          var priorityEntry = priorityEntries.OrderByDescending(x => x.Task.Priority).ThenBy(x => x.JobInfo.DateCreated).First();
+          if (defaultEntry.Task.Priority <= priorityEntry.Task.Priority) {
+            taskJobRelations.Remove(priorityEntry);
+            scheduledTasks.Add(priorityEntry.Task);
+            UpdateUserPriority(pm, userPriorities[priorityIndex]);
             priorityIndex++;
-            priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray();
-          }
-          if (priorityEntries.Any()) { // tasks with desired user priority found
-            var priorityEntry = priorityEntries.OrderByDescending(x => x.Task.Priority).ThenBy(x => x.JobInfo.DateCreated).First();
-            if (defaultEntry.Task.Priority <= priorityEntry.Task.Priority) {
-              taskJobRelations.Remove(priorityEntry);
-              scheduledTasks.Add(priorityEntry.Task);
-              UpdateUserPriority(pm, userPriorities[priorityIndex]);
-              priorityIndex++;
-            } else { // there are other tasks with higher priorities
-              taskJobRelations.Remove(defaultEntry);
-              scheduledTasks.Add(defaultEntry.Task);
-            }
-          } else {
+          } else { // there are other tasks with higher priorities
             taskJobRelations.Remove(defaultEntry);
             scheduledTasks.Add(defaultEntry.Task);
           }
-          if (priorityIndex >= (userPriorities.Length - 1)) priorityIndex = 0;
+        } else {
+          taskJobRelations.Remove(defaultEntry);
+          scheduledTasks.Add(defaultEntry.Task);
         }
-        return scheduledTasks;
+        if (priorityIndex >= (userPriorities.Length - 1)) priorityIndex = 0;
       }
+      return scheduledTasks;
+
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactClientInfoController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactClientInfoController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactClientInfoController.cs	(revision 12858)
@@ -36,28 +36,26 @@
 
     public DT.FactClientInfo GetFactClientInfo(DateTime start, DateTime end) {
-      using (var pm = PersistenceManager) {
-        var factClientInfo = pm.FactClientInfoDao;
-        var query = factClientInfo.GetAll().Where(x => x.Time >= start && x.Time <= end);
-        return new DT.FactClientInfo {
-          Rows = query.Count(),
-          Clients = query.Select(x => x.ClientId).Distinct().Count()
-        };
-      }
+      var pm = PersistenceManager;
+      var factClientInfo = pm.FactClientInfoDao;
+      var query = factClientInfo.GetAll().Where(x => x.Time >= start && x.Time <= end);
+      return new DT.FactClientInfo {
+        Rows = query.Count(),
+        Clients = query.Select(x => x.ClientId).Distinct().Count()
+      };
     }
 
     public void Aggregate(DateTime start, DateTime end, int entries) {
-      using (var pm = PersistenceManager) {
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var dimTimeDao = pm.DimTimeDao;
-        var clientIds = pm.UseTransaction(() => factClientInfoDao.GetAll()
-          .Where(x => x.Time >= start && x.Time <= end)
-          .Select(x => x.ClientId)
-          .Distinct()
-        );
-        foreach (var id in clientIds) {
-          AggregateClient(pm, id, start, end, entries);
-        }
-        dimTimeDao.DeleteUnusedTimes();
+      var pm = PersistenceManager;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var dimTimeDao = pm.DimTimeDao;
+      var clientIds = pm.UseTransaction(() => factClientInfoDao.GetAll()
+        .Where(x => x.Time >= start && x.Time <= end)
+        .Select(x => x.ClientId)
+        .Distinct()
+      );
+      foreach (var id in clientIds) {
+        AggregateClient(pm, id, start, end, entries);
       }
+      dimTimeDao.DeleteUnusedTimes();
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactTaskController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactTaskController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactTaskController.cs	(revision 12858)
@@ -35,47 +35,44 @@
 
     public DT.JobPage GetJobs(DateTime start, DateTime end, int page, int size) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var query = dimJobDao.GetAll().Where(x => x.DateCreated >= start && x.DateCreated <= end);
-          return new DT.JobPage {
-            TotalJobs = query.Count(),
-            Jobs = query.OrderBy(x => x.DateCreated)
-              .Skip((page - 1) * size)
-              .Take(size)
-              .Select(x => new DT.Job {
-                Id = x.JobId,
-                Name = x.JobName,
-                Username = x.UserName,
-                DateCreated = x.DateCreated,
-                Tasks = x.TotalTasks,
-                Aggregated = !(factTaskDao.GetAll().Count(y => y.JobId == x.JobId) > 1)
-              })
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var query = dimJobDao.GetAll().Where(x => x.DateCreated >= start && x.DateCreated <= end);
+        return new DT.JobPage {
+          TotalJobs = query.Count(),
+          Jobs = query.OrderBy(x => x.DateCreated)
+            .Skip((page - 1) * size)
+            .Take(size)
+            .Select(x => new DT.Job {
+              Id = x.JobId,
+              Name = x.JobName,
+              Username = x.UserName,
+              DateCreated = x.DateCreated,
+              Tasks = x.TotalTasks,
+              Aggregated = !(factTaskDao.GetAll().Count(y => y.JobId == x.JobId) > 1)
+            })
+            .ToList()
+        };
+      });
     }
 
     [HttpPost]
     public void AggregateJob(Guid id) {
-      using (var pm = PersistenceManager) {
-        AggregateJob(pm, id);
-      }
+      var pm = PersistenceManager;
+      AggregateJob(pm, id);
     }
 
     [HttpPost]
     public void AggregateAllJobs(DateTime start, DateTime end) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var jobIds = pm.UseTransaction(() => dimJobDao.GetAll()
-          .Where(x => x.DateCreated >= start && x.DateCreated <= end)
-          .Select(x => x.JobId)
-          .ToList()
-        );
-        foreach (var id in jobIds) {
-          AggregateJob(pm, id);
-        }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var jobIds = pm.UseTransaction(() => dimJobDao.GetAll()
+        .Where(x => x.DateCreated >= start && x.DateCreated <= end)
+        .Select(x => x.JobId)
+        .ToList()
+      );
+      foreach (var id in jobIds) {
+        AggregateJob(pm, id);
       }
     }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/PluginController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/PluginController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/PluginController.cs	(revision 12858)
@@ -34,51 +34,48 @@
 
     public DT.PluginPage GetUnusedPlugins(int page, int size) {
-      using (var pm = PersistenceManager) {
-        var pluginDao = pm.PluginDao;
-        var requiredPluginDao = pm.RequiredPluginDao;
-        var taskDao = pm.TaskDao;
-        return pm.UseTransaction(() => {
-          var taskIds = taskDao.GetAll().Select(x => x.TaskId);
-          var usedPluginIds = requiredPluginDao.GetAll()
-            .Where(x => taskIds.Contains(x.TaskId))
-            .Select(x => x.PluginId)
-            .Distinct();
-          var query = pluginDao.GetAll().Where(x => !usedPluginIds.Any(y => y == x.PluginId));
-          return new DT.PluginPage {
-            TotalPlugins = query.Count(),
-            Plugins = query.OrderBy(x => x.DateCreated).ThenBy(x => x.Name)
-              .Skip((page - 1) * size)
-              .Take(size).Select(x => new DT.Plugin {
-                Id = x.PluginId,
-                Name = x.Name,
-                Version = x.Version,
-                DateCreated = x.DateCreated
-              })
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var pluginDao = pm.PluginDao;
+      var requiredPluginDao = pm.RequiredPluginDao;
+      var taskDao = pm.TaskDao;
+      return pm.UseTransaction(() => {
+        var taskIds = taskDao.GetAll().Select(x => x.TaskId);
+        var usedPluginIds = requiredPluginDao.GetAll()
+          .Where(x => taskIds.Contains(x.TaskId))
+          .Select(x => x.PluginId)
+          .Distinct();
+        var query = pluginDao.GetAll().Where(x => !usedPluginIds.Any(y => y == x.PluginId));
+        return new DT.PluginPage {
+          TotalPlugins = query.Count(),
+          Plugins = query.OrderBy(x => x.DateCreated).ThenBy(x => x.Name)
+            .Skip((page - 1) * size)
+            .Take(size).Select(x => new DT.Plugin {
+              Id = x.PluginId,
+              Name = x.Name,
+              Version = x.Version,
+              DateCreated = x.DateCreated
+            })
+            .ToList()
+        };
+      });
     }
 
     [HttpPost]
     public void DeletePlugin(Guid id) {
-      using (var pm = PersistenceManager) {
-        var pluginDao = pm.PluginDao;
-        pm.UseTransaction(() => {
-          pluginDao.Delete(id);
-          pm.SubmitChanges();
-        });
-      }
+      var pm = PersistenceManager;
+      var pluginDao = pm.PluginDao;
+      pm.UseTransaction(() => {
+        pluginDao.Delete(id);
+        pm.SubmitChanges();
+      });
     }
 
     [HttpPost]
     public void DeleteUnusedPlugins() {
-      using (var pm = PersistenceManager) {
-        var pluginDao = pm.PluginDao;
-        pm.UseTransaction(() => {
-          pluginDao.DeleteUnusedPlugins();
-          pm.SubmitChanges();
-        });
-      }
+      var pm = PersistenceManager;
+      var pluginDao = pm.PluginDao;
+      pm.UseTransaction(() => {
+        pluginDao.DeleteUnusedPlugins();
+        pm.SubmitChanges();
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs	(revision 12858)
@@ -51,6 +51,6 @@
         "UserPriority"
       };
-      using (var pm = PersistenceManager) {
-        return pm.UseTransaction(() => (
+      var pm = PersistenceManager;
+      return pm.UseTransaction(() => (
           from table in tables
           select pm.GetTableInformation(table) into tableInformation
@@ -59,5 +59,4 @@
           ).ToList()
         );
-      }
     }
 
@@ -71,6 +70,6 @@
         "statistics.FactTask"
       };
-      using (var pm = PersistenceManager) {
-        return pm.UseTransaction(() => (
+      var pm = PersistenceManager;
+      return pm.UseTransaction(() => (
           from table in tables
           select pm.GetTableInformation(table) into tableInformation
@@ -79,5 +78,4 @@
           ).ToList()
         );
-      }
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs	(revision 12858)
@@ -38,111 +38,109 @@
 
     public DT.ClientDetails GetClientDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var timeData = factClientInfoDao.GetByClientId(id)
-            .GroupBy(x => x.ClientId)
-            .Select(x => new {
-              TotalIdleTime = x.Sum(y => y.IdleTime),
-              TotalOfflineTime = x.Sum(y => y.OfflineTime),
-              TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
-            }).FirstOrDefault();
-          var taskTimeData = factTaskDao.GetByClientId(id)
-            .GroupBy(x => x.LastClientId)
-            .Select(x => new {
-              TotalCalculatingTime = x.Sum(y => y.CalculatingTime),
-              TotalTransferringTime = x.Sum(y => y.TransferTime)
-            }).FirstOrDefault();
-          var startDate = factClientInfoDao.GetByClientId(id)
-            .Where(x => x.SlaveState == SlaveState.Offline)
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var timeData = factClientInfoDao.GetByClientId(id)
+          .GroupBy(x => x.ClientId)
+          .Select(x => new {
+            TotalIdleTime = x.Sum(y => y.IdleTime),
+            TotalOfflineTime = x.Sum(y => y.OfflineTime),
+            TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
+          }).FirstOrDefault();
+        var taskTimeData = factTaskDao.GetByClientId(id)
+          .GroupBy(x => x.LastClientId)
+          .Select(x => new {
+            TotalCalculatingTime = x.Sum(y => y.CalculatingTime),
+            TotalTransferringTime = x.Sum(y => y.TransferTime)
+          }).FirstOrDefault();
+        var startDate = factClientInfoDao.GetByClientId(id)
+          .Where(x => x.SlaveState == SlaveState.Offline)
+          .OrderByDescending(x => x.Time)
+          .Select(x => x.Time).FirstOrDefault();
+        long upTime = 0;
+        if (startDate == default(DateTime)) {
+          startDate = factClientInfoDao.GetByClientId(id)
             .OrderByDescending(x => x.Time)
-            .Select(x => x.Time).FirstOrDefault();
-          long upTime = 0;
-          if (startDate == default(DateTime)) {
-            startDate = factClientInfoDao.GetByClientId(id)
-              .OrderByDescending(x => x.Time)
-              .Select(x => x.Time)
-              .FirstOrDefault();
-          }
-          if (startDate != default(DateTime)) {
-            upTime = (long)(DateTime.Now - startDate).TotalSeconds;
-          }
-          return (from client in dimClientDao.GetAll().Where(x => x.Id == id)
-                  join info in factClientInfoDao.GetAll()
-                    on client.Id equals info.ClientId into clientInfoJoin
-                  from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                  let offline = (client.ExpirationTime != null || clientInfo.SlaveState == SlaveState.Offline)
-                  select new DT.ClientDetails {
-                    Id = client.Id,
-                    Name = client.Name,
-                    TotalCores = clientInfo.NumTotalCores,
-                    UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                    TotalMemory = clientInfo.TotalMemory,
-                    UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                    CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                    State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                    LastUpdate = clientInfo.Time,
-                    GroupId = client.ResourceGroupId,
-                    GroupName = client.GroupName,
-                    UpTime = offline ? 0 : upTime,
-                    TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0,
-                    TotalCalculatingTime = taskTimeData != null ? taskTimeData.TotalCalculatingTime : 0,
-                    TotalIdleTime = timeData != null ? timeData.TotalIdleTime : 0,
-                    TotalOfflineTime = timeData != null ? timeData.TotalOfflineTime : 0,
-                    TotalTransferringTime = taskTimeData != null ? taskTimeData.TotalTransferringTime : 0,
-                    TasksStates = factTaskDao.GetByClientId(id)
-                                    .GroupBy(x => x.TaskState)
-                                    .Select(x => new DT.TaskStateCount {
-                                      State = x.Key.ToString(),
-                                      Count = x.Count()
-                                    }).ToList(),
-                    Users = factTaskDao.GetAll()
-                              .Where(x => x.LastClientId == id)
-                              .Select(x => new DT.User {
-                                Id = x.DimJob.UserId,
-                                Name = x.DimJob.UserName
-                              })
-                              .Distinct()
-                              .ToList()
-                  })
-                  .FirstOrDefault();
-        });
-      }
+            .Select(x => x.Time)
+            .FirstOrDefault();
+        }
+        if (startDate != default(DateTime)) {
+          upTime = (long)(DateTime.Now - startDate).TotalSeconds;
+        }
+        return (from client in dimClientDao.GetAll().Where(x => x.Id == id)
+                join info in factClientInfoDao.GetAll()
+                  on client.Id equals info.ClientId into clientInfoJoin
+                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                let offline = (client.ExpirationTime != null || clientInfo.SlaveState == SlaveState.Offline)
+                select new DT.ClientDetails {
+                  Id = client.Id,
+                  Name = client.Name,
+                  TotalCores = clientInfo.NumTotalCores,
+                  UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                  TotalMemory = clientInfo.TotalMemory,
+                  UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                  CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                  State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                  LastUpdate = clientInfo.Time,
+                  GroupId = client.ResourceGroupId,
+                  GroupName = client.GroupName,
+                  UpTime = offline ? 0 : upTime,
+                  TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0,
+                  TotalCalculatingTime = taskTimeData != null ? taskTimeData.TotalCalculatingTime : 0,
+                  TotalIdleTime = timeData != null ? timeData.TotalIdleTime : 0,
+                  TotalOfflineTime = timeData != null ? timeData.TotalOfflineTime : 0,
+                  TotalTransferringTime = taskTimeData != null ? taskTimeData.TotalTransferringTime : 0,
+                  TasksStates = factTaskDao.GetByClientId(id)
+                                  .GroupBy(x => x.TaskState)
+                                  .Select(x => new DT.TaskStateCount {
+                                    State = x.Key.ToString(),
+                                    Count = x.Count()
+                                  }).ToList(),
+                  Users = factTaskDao.GetAll()
+                            .Where(x => x.LastClientId == id)
+                            .Select(x => new DT.User {
+                              Id = x.DimJob.UserId,
+                              Name = x.DimJob.UserName
+                            })
+                            .Distinct()
+                            .ToList()
+                })
+                .FirstOrDefault();
+      });
     }
 
     public DT.ClientPage GetClients(int page, int size, bool expired = false) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        return pm.UseTransaction(() => {
-          var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
-          var query = (from client in clients
-                       join info in factClientInfoDao.GetAll()
-                         on client.Id equals info.ClientId into clientInfoJoin
-                       from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                       let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
-                       select new DT.Client {
-                         Id = client.Id,
-                         Name = client.Name,
-                         TotalCores = clientInfo.NumTotalCores,
-                         UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                         TotalMemory = clientInfo.TotalMemory,
-                         UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                         CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                         State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                         GroupId = client.ResourceGroupId,
-                         GroupName = client.GroupName,
-                         IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
-                       });
-          return new DT.ClientPage {
-            TotalClients = query.Count(),
-            Clients = query.Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      return pm.UseTransaction(() => {
+        var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
+        var query = (from client in clients
+                     join info in factClientInfoDao.GetAll()
+                       on client.Id equals info.ClientId into clientInfoJoin
+                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
+                     select new DT.Client {
+                       Id = client.Id,
+                       Name = client.Name,
+                       TotalCores = clientInfo.NumTotalCores,
+                       UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                       TotalMemory = clientInfo.TotalMemory,
+                       UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                       GroupId = client.ResourceGroupId,
+                       GroupName = client.GroupName,
+                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
+                     });
+        return new DT.ClientPage {
+          TotalClients = query.Count(),
+          Clients = query.Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
+        };
+      });
     }
 
@@ -155,80 +153,78 @@
         increment += 5;
       }
-      using (var pm = PersistenceManager) {
-        var factClientInfo = pm.FactClientInfoDao;
-        var clientInfos = factClientInfo.GetByClientId(id)
-          .Where(x => x.Time >= start && x.Time <= end)
-          .OrderBy(x => x.Time)
-          .ToList();
-        var clientStatus = new DT.ClientStatus {
-          CpuUtilization = 0,
-          TotalCores = 0,
-          UsedCores = 0,
-          TotalMemory = 0,
-          UsedMemory = 0
+      var pm = PersistenceManager;
+      var factClientInfo = pm.FactClientInfoDao;
+      var clientInfos = factClientInfo.GetByClientId(id)
+        .Where(x => x.Time >= start && x.Time <= end)
+        .OrderBy(x => x.Time)
+        .ToList();
+      var clientStatus = new DT.ClientStatus {
+        CpuUtilization = 0,
+        TotalCores = 0,
+        UsedCores = 0,
+        TotalMemory = 0,
+        UsedMemory = 0
+      };
+      int i = 1;
+      foreach (var clientInfo in clientInfos) {
+        clientStatus.CpuUtilization += clientInfo.CpuUtilization;
+        clientStatus.TotalCores += clientInfo.NumTotalCores;
+        clientStatus.UsedCores += clientInfo.NumUsedCores;
+        clientStatus.TotalMemory += clientInfo.TotalMemory;
+        clientStatus.UsedMemory += clientInfo.UsedMemory;
+        if (i >= increment) {
+          clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
+          clientStatus.CpuUtilization /= i;
+          clientStatus.TotalCores /= i;
+          clientStatus.UsedCores /= i;
+          clientStatus.TotalMemory /= i;
+          clientStatus.UsedMemory /= i;
+          yield return clientStatus;
+          clientStatus = new DT.ClientStatus {
+            CpuUtilization = 0,
+            TotalCores = 0,
+            UsedCores = 0,
+            TotalMemory = 0,
+            UsedMemory = 0
+          };
+          i = 1;
+        } else {
+          ++i;
+        }
+      }
+    }
+
+    public DT.ClientPage GetClientsByGroupId(Guid id, int page, int size, bool expired = false) {
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      return pm.UseTransaction(() => {
+        var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
+        clients = clients.Where(x => x.ResourceGroupId == id);
+        var query = (from client in clients
+                     join info in factClientInfoDao.GetAll()
+                       on client.Id equals info.ClientId into clientInfoJoin
+                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
+                     select new DT.Client {
+                       Id = client.Id,
+                       Name = client.Name,
+                       TotalCores = clientInfo.NumTotalCores,
+                       UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                       TotalMemory = clientInfo.TotalMemory,
+                       UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
+                       GroupId = client.ResourceGroupId,
+                       GroupName = client.GroupName,
+                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
+                     });
+        return new DT.ClientPage {
+          TotalClients = query.Count(),
+          Clients = query.Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
         };
-        int i = 1;
-        foreach (var clientInfo in clientInfos) {
-          clientStatus.CpuUtilization += clientInfo.CpuUtilization;
-          clientStatus.TotalCores += clientInfo.NumTotalCores;
-          clientStatus.UsedCores += clientInfo.NumUsedCores;
-          clientStatus.TotalMemory += clientInfo.TotalMemory;
-          clientStatus.UsedMemory += clientInfo.UsedMemory;
-          if (i >= increment) {
-            clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
-            clientStatus.CpuUtilization /= i;
-            clientStatus.TotalCores /= i;
-            clientStatus.UsedCores /= i;
-            clientStatus.TotalMemory /= i;
-            clientStatus.UsedMemory /= i;
-            yield return clientStatus;
-            clientStatus = new DT.ClientStatus {
-              CpuUtilization = 0,
-              TotalCores = 0,
-              UsedCores = 0,
-              TotalMemory = 0,
-              UsedMemory = 0
-            };
-            i = 1;
-          } else {
-            ++i;
-          }
-        }
-      }
-    }
-
-    public DT.ClientPage GetClientsByGroupId(Guid id, int page, int size, bool expired = false) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        return pm.UseTransaction(() => {
-          var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
-          clients = clients.Where(x => x.ResourceGroupId == id);
-          var query = (from client in clients
-                       join info in factClientInfoDao.GetAll()
-                         on client.Id equals info.ClientId into clientInfoJoin
-                       from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                       let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
-                       select new DT.Client {
-                         Id = client.Id,
-                         Name = client.Name,
-                         TotalCores = clientInfo.NumTotalCores,
-                         UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                         TotalMemory = clientInfo.TotalMemory,
-                         UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                         CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                         State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
-                         GroupId = client.ResourceGroupId,
-                         GroupName = client.GroupName,
-                         IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
-                       });
-          return new DT.ClientPage {
-            TotalClients = query.Count(),
-            Clients = query.Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      });
     }
 
@@ -241,57 +237,56 @@
         increment += 5;
       }
-      using (var pm = PersistenceManager) {
-        var factClientInfo = pm.FactClientInfoDao;
-        var dimClientDao = pm.DimClientDao;
-        var clientInfos = factClientInfo.GetAll()
-          .Where(x => x.Time >= start && x.Time <= end)
-          .OrderBy(x => x.Time)
-          .Join(dimClientDao.GetAll(),
-            fact => fact.ClientId,
-            client => client.Id,
-            (fact, client) => new {
-              client.ResourceGroupId,
-              fact.Time,
-              fact.CpuUtilization,
-              fact.NumTotalCores,
-              fact.NumUsedCores,
-              fact.TotalMemory,
-              fact.UsedMemory
-            })
-          .Where(x => x.ResourceGroupId == id)
-          .ToList();
-        var clientStatus = new DT.ClientStatus {
-          CpuUtilization = 0,
-          TotalCores = 0,
-          UsedCores = 0,
-          TotalMemory = 0,
-          UsedMemory = 0
-        };
-        int i = 1;
-        foreach (var clientInfo in clientInfos) {
-          clientStatus.CpuUtilization += clientInfo.CpuUtilization;
-          clientStatus.TotalCores += clientInfo.NumTotalCores;
-          clientStatus.UsedCores += clientInfo.NumUsedCores;
-          clientStatus.TotalMemory += clientInfo.TotalMemory;
-          clientStatus.UsedMemory += clientInfo.UsedMemory;
-          if (i >= increment) {
-            clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
-            clientStatus.CpuUtilization /= i;
-            clientStatus.TotalCores /= i;
-            clientStatus.UsedCores /= i;
-            clientStatus.TotalMemory /= i;
-            clientStatus.UsedMemory /= i;
-            yield return clientStatus;
-            clientStatus = new DT.ClientStatus {
-              CpuUtilization = 0,
-              TotalCores = 0,
-              UsedCores = 0,
-              TotalMemory = 0,
-              UsedMemory = 0
-            };
-            i = 1;
-          } else {
-            ++i;
-          }
+      var pm = PersistenceManager;
+      var factClientInfo = pm.FactClientInfoDao;
+      var dimClientDao = pm.DimClientDao;
+      var clientInfos = factClientInfo.GetAll()
+        .Where(x => x.Time >= start && x.Time <= end)
+        .OrderBy(x => x.Time)
+        .Join(dimClientDao.GetAll(),
+          fact => fact.ClientId,
+          client => client.Id,
+          (fact, client) => new {
+            client.ResourceGroupId,
+            fact.Time,
+            fact.CpuUtilization,
+            fact.NumTotalCores,
+            fact.NumUsedCores,
+            fact.TotalMemory,
+            fact.UsedMemory
+          })
+        .Where(x => x.ResourceGroupId == id)
+        .ToList();
+      var clientStatus = new DT.ClientStatus {
+        CpuUtilization = 0,
+        TotalCores = 0,
+        UsedCores = 0,
+        TotalMemory = 0,
+        UsedMemory = 0
+      };
+      int i = 1;
+      foreach (var clientInfo in clientInfos) {
+        clientStatus.CpuUtilization += clientInfo.CpuUtilization;
+        clientStatus.TotalCores += clientInfo.NumTotalCores;
+        clientStatus.UsedCores += clientInfo.NumUsedCores;
+        clientStatus.TotalMemory += clientInfo.TotalMemory;
+        clientStatus.UsedMemory += clientInfo.UsedMemory;
+        if (i >= increment) {
+          clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time);
+          clientStatus.CpuUtilization /= i;
+          clientStatus.TotalCores /= i;
+          clientStatus.UsedCores /= i;
+          clientStatus.TotalMemory /= i;
+          clientStatus.UsedMemory /= i;
+          yield return clientStatus;
+          clientStatus = new DT.ClientStatus {
+            CpuUtilization = 0,
+            TotalCores = 0,
+            UsedCores = 0,
+            TotalMemory = 0,
+            UsedMemory = 0
+          };
+          i = 1;
+        } else {
+          ++i;
         }
       }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ExceptionController.cs	(revision 12858)
@@ -35,34 +35,33 @@
 
     public DT.ExceptionPage GetExceptions(int page, int size) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var dimJobDao = pm.DimJobDao;
-        var factTaskDao = pm.FactTaskDao;
-        var tasks = factTaskDao.GetTasksWithException();
-        return pm.UseTransaction(() => new DT.ExceptionPage {
-          TotalExceptions = tasks.Count(),
-          Exceptions = (from factTask in tasks
-                        join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                        join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                          dimClient.Id into taskClientJoin
-                        from a in taskClientJoin.DefaultIfEmpty()
-                        let endTime = factTask.EndTime ?? DateTime.Now
-                        select new DT.Exception {
-                          TaskId = factTask.TaskId,
-                          JobId = factTask.JobId,
-                          JobName = dimJob.JobName,
-                          UserId = dimJob.UserId,
-                          UserName = dimJob.UserName,
-                          ClientId = factTask.LastClientId ?? default(Guid),
-                          ClientName = a != null ? a.Name : string.Empty,
-                          Date = endTime,
-                          Details = factTask.Exception
-                        })
-                        .OrderByDescending(x => x.Date)
-                        .Skip((page - 1) * size)
-                        .Take(size)
-                        .ToList()
-        });
-      }
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var dimJobDao = pm.DimJobDao;
+      var factTaskDao = pm.FactTaskDao;
+      var tasks = factTaskDao.GetTasksWithException();
+      return pm.UseTransaction(() => new DT.ExceptionPage {
+        TotalExceptions = tasks.Count(),
+        Exceptions = (from factTask in tasks
+                      join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                      join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                        dimClient.Id into taskClientJoin
+                      from a in taskClientJoin.DefaultIfEmpty()
+                      let endTime = factTask.EndTime ?? DateTime.Now
+                      select new DT.Exception {
+                        TaskId = factTask.TaskId,
+                        JobId = factTask.JobId,
+                        JobName = dimJob.JobName,
+                        UserId = dimJob.UserId,
+                        UserName = dimJob.UserName,
+                        ClientId = factTask.LastClientId ?? default(Guid),
+                        ClientName = a != null ? a.Name : string.Empty,
+                        Date = endTime,
+                        Details = factTask.Exception
+                      })
+                      .OrderByDescending(x => x.Date)
+                      .Skip((page - 1) * size)
+                      .Take(size)
+                      .ToList()
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs	(revision 12858)
@@ -35,38 +35,84 @@
 
     public DT.GroupDetails GetGroupDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var clientTimeData = factClientInfoDao.GetAll()
-            .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new {
-              y.ResourceGroupId,
-              x.IdleTime,
-              x.OfflineTime,
-              x.UnavailableTime
-            })
-            .Where(x => x.ResourceGroupId == id)
-            .GroupBy(x => x.ResourceGroupId)
-            .Select(x => new {
-              TotalIdleTime = x.Sum(y => y.IdleTime),
-              TotalOfflineTime = x.Sum(y => y.OfflineTime),
-              TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
-            })
-            .FirstOrDefault();
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var clientTimeData = factClientInfoDao.GetAll()
+          .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new {
+            y.ResourceGroupId,
+            x.IdleTime,
+            x.OfflineTime,
+            x.UnavailableTime
+          })
+          .Where(x => x.ResourceGroupId == id)
+          .GroupBy(x => x.ResourceGroupId)
+          .Select(x => new {
+            TotalIdleTime = x.Sum(y => y.IdleTime),
+            TotalOfflineTime = x.Sum(y => y.OfflineTime),
+            TotalUnavailableTime = x.Sum(y => y.UnavailableTime)
+          })
+          .FirstOrDefault();
 
-          var taskTimeData = factTaskDao.GetByGroupId(id)
-            .Select(x => new {
-              id,
-              x.CalculatingTime,
-              x.TransferTime
-            })
-            .GroupBy(x => x.id)
-            .Select(x => new {
-              CalculatingTime = x.Sum(y => y.CalculatingTime),
-              TransferTime = x.Sum(y => y.TransferTime)
-            })
-            .FirstOrDefault();
-          return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id)
+        var taskTimeData = factTaskDao.GetByGroupId(id)
+          .Select(x => new {
+            id,
+            x.CalculatingTime,
+            x.TransferTime
+          })
+          .GroupBy(x => x.id)
+          .Select(x => new {
+            CalculatingTime = x.Sum(y => y.CalculatingTime),
+            TransferTime = x.Sum(y => y.TransferTime)
+          })
+          .FirstOrDefault();
+        return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id)
+                join info in factClientInfoDao.GetAll()
+                  on client.Id equals info.ClientId into clientInfoJoin
+                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
+                let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
+                select new {
+                  ResourceGroupId = client.ResourceGroupId,
+                  GroupName = client.GroupName,
+                  TotalCores = clientInfo.NumTotalCores,
+                  UsedCores = offline ? 0 : clientInfo.NumUsedCores,
+                  TotalMemory = clientInfo.TotalMemory,
+                  UsedMemory = offline ? 0 : clientInfo.UsedMemory,
+                  CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
+                  SlaveState = clientInfo.SlaveState
+                })
+          .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
+          .Select(x => new DT.GroupDetails {
+            Id = id,
+            Name = x.Key.GroupName,
+            TotalClients = x.Count(),
+            OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
+            TotalCores = x.Sum(y => y.TotalCores),
+            UsedCores = x.Sum(y => y.UsedCores),
+            TotalMemory = x.Sum(y => y.TotalMemory),
+            UsedMemory = x.Sum(y => y.UsedMemory),
+            TotalCpuUtilization = x.Average(y => (double?)y.CpuUtilization) ?? 0.0,
+            ActiveCpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0,
+            TotalUnavailableTime = clientTimeData != null ? clientTimeData.TotalUnavailableTime : 0,
+            TotalCalculatingTime = taskTimeData != null ? taskTimeData.CalculatingTime : 0,
+            TotalIdleTime = clientTimeData != null ? clientTimeData.TotalIdleTime : 0,
+            TotalOfflineTime = clientTimeData != null ? clientTimeData.TotalOfflineTime : 0,
+            TotalTransferringTime = taskTimeData != null ? taskTimeData.TransferTime : 0,
+            TasksStates = factTaskDao.GetByGroupId(id)
+                                  .GroupBy(y => y.TaskState)
+                                  .Select(y => new DT.TaskStateCount {
+                                    State = y.Key.ToString(),
+                                    Count = y.Count()
+                                  }).ToList()
+          }).FirstOrDefault();
+      });
+    }
+
+    public DT.GroupPage GetGroups(int page, int size) {
+      var pm = PersistenceManager;
+      var dimClientDao = pm.DimClientDao;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var data = (from client in dimClientDao.GetActiveClients()
                   join info in factClientInfoDao.GetAll()
                     on client.Id equals info.ClientId into clientInfoJoin
@@ -75,5 +121,4 @@
                   select new {
                     ResourceGroupId = client.ResourceGroupId,
-                    GroupName = client.GroupName,
                     TotalCores = clientInfo.NumTotalCores,
                     UsedCores = offline ? 0 : clientInfo.NumUsedCores,
@@ -82,85 +127,38 @@
                     CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
                     SlaveState = clientInfo.SlaveState
-                  })
-            .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
-            .Select(x => new DT.GroupDetails {
-              Id = id,
-              Name = x.Key.GroupName,
-              TotalClients = x.Count(),
-              OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
-              TotalCores = x.Sum(y => y.TotalCores),
-              UsedCores = x.Sum(y => y.UsedCores),
-              TotalMemory = x.Sum(y => y.TotalMemory),
-              UsedMemory = x.Sum(y => y.UsedMemory),
-              TotalCpuUtilization = x.Average(y => (double?)y.CpuUtilization) ?? 0.0,
-              ActiveCpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0,
-              TotalUnavailableTime = clientTimeData != null ? clientTimeData.TotalUnavailableTime : 0,
-              TotalCalculatingTime = taskTimeData != null ? taskTimeData.CalculatingTime : 0,
-              TotalIdleTime = clientTimeData != null ? clientTimeData.TotalIdleTime : 0,
-              TotalOfflineTime = clientTimeData != null ? clientTimeData.TotalOfflineTime : 0,
-              TotalTransferringTime = taskTimeData != null ? taskTimeData.TransferTime : 0,
-              TasksStates = factTaskDao.GetByGroupId(id)
-                                    .GroupBy(y => y.TaskState)
-                                    .Select(y => new DT.TaskStateCount {
-                                      State = y.Key.ToString(),
-                                      Count = y.Count()
-                                    }).ToList()
-            }).FirstOrDefault();
+                  }).GroupBy(x => x.ResourceGroupId).Select(x => new {
+                    GroupId = x.Key,
+                    TotalClients = x.Count(),
+                    OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
+                    TotalCores = x.Sum(y => y.TotalCores),
+                    UsedCores = x.Sum(y => y.UsedCores),
+                    TotalMemory = x.Sum(y => y.TotalMemory),
+                    UsedMemory = x.Sum(y => y.UsedMemory),
+                    CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0
+                  });
+      var query = dimClientDao.GetAll()
+        .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
+        .Select(x => new {
+          Id = x.Key.ResourceGroupId ?? default(Guid),
+          Name = x.Key.GroupName
         });
-      }
-    }
-
-    public DT.GroupPage GetGroups(int page, int size) {
-      using (var pm = PersistenceManager) {
-        var dimClientDao = pm.DimClientDao;
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var data = (from client in dimClientDao.GetActiveClients()
-                    join info in factClientInfoDao.GetAll()
-                      on client.Id equals info.ClientId into clientInfoJoin
-                    from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
-                    let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
-                    select new {
-                      ResourceGroupId = client.ResourceGroupId,
-                      TotalCores = clientInfo.NumTotalCores,
-                      UsedCores = offline ? 0 : clientInfo.NumUsedCores,
-                      TotalMemory = clientInfo.TotalMemory,
-                      UsedMemory = offline ? 0 : clientInfo.UsedMemory,
-                      CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
-                      SlaveState = clientInfo.SlaveState
-                    }).GroupBy(x => x.ResourceGroupId).Select(x => new {
-                      GroupId = x.Key,
-                      TotalClients = x.Count(),
-                      OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline),
-                      TotalCores = x.Sum(y => y.TotalCores),
-                      UsedCores = x.Sum(y => y.UsedCores),
-                      TotalMemory = x.Sum(y => y.TotalMemory),
-                      UsedMemory = x.Sum(y => y.UsedMemory),
-                      CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0
-                    });
-        var query = dimClientDao.GetAll()
-          .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
-          .Select(x => new {
-            Id = x.Key.ResourceGroupId ?? default(Guid),
-            Name = x.Key.GroupName
-          });
-        return pm.UseTransaction(() => new DT.GroupPage {
-          TotalGroups = query.Count(),
-          Groups = query
-          .Skip((page - 1) * size)
-          .Take(size)
-          .Join(data, x => x.Id, y => y.GroupId,
-            (group, info) => new DT.Group {
-              Id = group.Id,
-              Name = group.Name,
-              TotalClients = info.TotalClients,
-              OnlineClients = info.OnlineClients,
-              TotalCores = info.TotalCores,
-              UsedCores = info.UsedCores,
-              TotalMemory = info.TotalMemory,
-              UsedMemory = info.UsedMemory,
-              CpuUtilization = info.CpuUtilization
-            }).ToList()
-        });
-      }
+      return pm.UseTransaction(() => new DT.GroupPage {
+        TotalGroups = query.Count(),
+        Groups = query
+        .Skip((page - 1) * size)
+        .Take(size)
+        .Join(data, x => x.Id, y => y.GroupId,
+          (group, info) => new DT.Group {
+            Id = group.Id,
+            Name = group.Name,
+            TotalClients = info.TotalClients,
+            OnlineClients = info.OnlineClients,
+            TotalCores = info.TotalCores,
+            UsedCores = info.UsedCores,
+            TotalMemory = info.TotalMemory,
+            UsedMemory = info.UsedMemory,
+            CpuUtilization = info.CpuUtilization
+          }).ToList()
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs	(revision 12858)
@@ -47,47 +47,46 @@
 
     public DT.JobDetails GetJobDetails(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var job = dimJobDao.GetById(id);
-          if (job != null) {
-            var timeData = factTaskDao.GetByJobId(id).GroupBy(x => x.JobId).Select(x => new {
-              AvgTransferringTime = (long)x.Average(y => y.TransferTime),
-              MinCalculatingTime = (long)x.Min(y => y.CalculatingTime),
-              MaxCalculatingTime = (long)x.Max(y => y.CalculatingTime),
-              AvgCalculatingTime = (long)x.Average(y => y.CalculatingTime),
-              TotalCalculatingTime = (long)x.Sum(y => y.CalculatingTime),
-              TotalWaitingTime = (long)x.Sum(y => y.WaitingTime)
-            }).FirstOrDefault();
-            DateTime endTime = job.DateCompleted ?? DateTime.Now;
-            long totalTime = (long)(endTime - job.DateCreated).TotalSeconds;
-            return new DT.JobDetails {
-              Id = job.JobId,
-              Name = job.JobName,
-              UserId = job.UserId,
-              UserName = job.UserName,
-              DateCreated = job.DateCreated,
-              DateCompleted = job.DateCompleted,
-              TotalTasks = job.TotalTasks,
-              CompletedTasks = job.CompletedTasks,
-              AvgTransferringTime = timeData != null ? timeData.AvgTransferringTime : 0,
-              AvgCalculatingTime = timeData != null ? timeData.AvgCalculatingTime : 0,
-              MinCalculatingTime = timeData != null ? timeData.MinCalculatingTime : 0,
-              MaxCalculatingTime = timeData != null ? timeData.MaxCalculatingTime : 0,
-              TotalCalculatingTime = timeData != null ? timeData.TotalCalculatingTime : 0,
-              TotalWaitingTime = timeData != null ? timeData.TotalWaitingTime : 0,
-              TotalTime = totalTime,
-              TasksStates = factTaskDao.GetByJobId(id)
-                            .GroupBy(x => x.TaskState)
-                            .Select(x => new DT.TaskStateCount {
-                              State = x.Key.ToString(),
-                              Count = x.Count()
-                            }).ToList()
-            };
-          }
-          return null;
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var job = dimJobDao.GetById(id);
+        if (job != null) {
+          var timeData = factTaskDao.GetByJobId(id).GroupBy(x => x.JobId).Select(x => new {
+            AvgTransferringTime = (long)x.Average(y => y.TransferTime),
+            MinCalculatingTime = (long)x.Min(y => y.CalculatingTime),
+            MaxCalculatingTime = (long)x.Max(y => y.CalculatingTime),
+            AvgCalculatingTime = (long)x.Average(y => y.CalculatingTime),
+            TotalCalculatingTime = (long)x.Sum(y => y.CalculatingTime),
+            TotalWaitingTime = (long)x.Sum(y => y.WaitingTime)
+          }).FirstOrDefault();
+          DateTime endTime = job.DateCompleted ?? DateTime.Now;
+          long totalTime = (long)(endTime - job.DateCreated).TotalSeconds;
+          return new DT.JobDetails {
+            Id = job.JobId,
+            Name = job.JobName,
+            UserId = job.UserId,
+            UserName = job.UserName,
+            DateCreated = job.DateCreated,
+            DateCompleted = job.DateCompleted,
+            TotalTasks = job.TotalTasks,
+            CompletedTasks = job.CompletedTasks,
+            AvgTransferringTime = timeData != null ? timeData.AvgTransferringTime : 0,
+            AvgCalculatingTime = timeData != null ? timeData.AvgCalculatingTime : 0,
+            MinCalculatingTime = timeData != null ? timeData.MinCalculatingTime : 0,
+            MaxCalculatingTime = timeData != null ? timeData.MaxCalculatingTime : 0,
+            TotalCalculatingTime = timeData != null ? timeData.TotalCalculatingTime : 0,
+            TotalWaitingTime = timeData != null ? timeData.TotalWaitingTime : 0,
+            TotalTime = totalTime,
+            TasksStates = factTaskDao.GetByJobId(id)
+                          .GroupBy(x => x.TaskState)
+                          .Select(x => new DT.TaskStateCount {
+                            State = x.Key.ToString(),
+                            Count = x.Count()
+                          }).ToList()
+          };
+        }
+        return null;
+      });
     }
 
@@ -100,18 +99,17 @@
         RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
       }
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          var jobs = dimJobDao.GetByUserId(id).Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null));
-          return new DT.JobPage {
-            TotalJobs = jobs.Count(),
-            Jobs = jobs.OrderByDescending(x => x.DateCompleted ?? DateTime.MaxValue)
-              .Skip((page - 1) * size)
-              .Take(size)
-              .Select(x => ConvertToDT(x))
-              .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        var jobs = dimJobDao.GetByUserId(id).Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null));
+        return new DT.JobPage {
+          TotalJobs = jobs.Count(),
+          Jobs = jobs.OrderByDescending(x => x.DateCompleted ?? DateTime.MaxValue)
+            .Skip((page - 1) * size)
+            .Take(size)
+            .Select(x => ConvertToDT(x))
+            .ToList()
+        };
+      });
     }
 
@@ -124,27 +122,25 @@
         RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
       }
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          return dimJobDao.GetByUserId(id)
-            .Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null))
-            .Select(x => ConvertToDT(x))
-            .ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        return dimJobDao.GetByUserId(id)
+          .Where(x => completed ? (x.DateCompleted != null) : (x.DateCompleted == null))
+          .Select(x => ConvertToDT(x))
+          .ToList();
+      });
     }
 
     [Authorize(Roles = HiveRoles.Administrator)]
     public IEnumerable<DT.Job> GetAllActiveJobsFromAllUsers() {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        return pm.UseTransaction(() => {
-          return dimJobDao.GetAll()
-            .Where(x => x.DateCompleted == null)
-            .OrderByDescending(x => x.DateCreated)
-            .Select(x => ConvertToDT(x))
-            .ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      return pm.UseTransaction(() => {
+        return dimJobDao.GetAll()
+          .Where(x => x.DateCompleted == null)
+          .OrderByDescending(x => x.DateCreated)
+          .Select(x => ConvertToDT(x))
+          .ToList();
+      });
     }
 
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs	(revision 12858)
@@ -51,57 +51,56 @@
     [HttpPost]
     public DT.TaskPage GetTasksByJobId(Guid id, int page, int size, IEnumerable<string> states) {
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var dimClientDao = pm.DimClientDao;
-        var factTaskDao = pm.FactTaskDao;
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var dimClientDao = pm.DimClientDao;
+      var factTaskDao = pm.FactTaskDao;
 
-        DA.DimJob job = pm.UseTransaction(() => dimJobDao.GetById(id));
-        if (job == null) {
-          throw new ArgumentException("invalid job id");
-        }
-        if (job.UserId != UserManager.CurrentUserId) {
-          RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
-        }
+      DA.DimJob job = pm.UseTransaction(() => dimJobDao.GetById(id));
+      if (job == null) {
+        throw new ArgumentException("invalid job id");
+      }
+      if (job.UserId != UserManager.CurrentUserId) {
+        RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
+      }
 
-        return pm.UseTransaction(() => {
-          var tasks = factTaskDao.GetByJobId(id).Where(x => states.Contains(x.TaskState.ToString()));
-          return new DT.TaskPage {
-            TotalTasks = tasks.Count(),
-            Tasks = (from factTask in tasks
-                     join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                     join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                       dimClient.Id into taskClientJoin
-                     from a in taskClientJoin.DefaultIfEmpty()
-                     let startTime = factTask.StartTime ?? DateTime.Now
-                     let endTime = factTask.EndTime ?? DateTime.Now
-                     select new DT.Task {
-                       Id = factTask.TaskId,
-                       JobId = factTask.JobId,
-                       JobName = dimJob.JobName,
-                       TotalTime = (long)(endTime - startTime).TotalSeconds,
-                       CalculatingTime = factTask.CalculatingTime,
-                       WaitingTime = factTask.WaitingTime,
-                       TransferTime = factTask.TransferTime,
-                       InitialWaitingTime = factTask.InitialWaitingTime,
-                       NumCalculationRuns = factTask.NumCalculationRuns,
-                       NumRetries = factTask.NumRetries,
-                       CoresRequired = factTask.CoresRequired,
-                       MemoryRequired = factTask.MemoryRequired,
-                       Priority = factTask.Priority,
-                       State = factTask.TaskState.ToString(),
-                       LastClientId = factTask.LastClientId,
-                       LastClientName = a != null ? a.Name : string.Empty,
-                       UserId = dimJob.UserId,
-                       UserName = dimJob.UserName,
-                       StartTime = factTask.StartTime,
-                       EndTime = factTask.EndTime,
-                       Exception = factTask.Exception
-                     })
-              .Skip((page - 1) * size)
-              .Take(size)
-              .ToList()
-          };
-        });
-      }
+      return pm.UseTransaction(() => {
+        var tasks = factTaskDao.GetByJobId(id).Where(x => states.Contains(x.TaskState.ToString()));
+        return new DT.TaskPage {
+          TotalTasks = tasks.Count(),
+          Tasks = (from factTask in tasks
+                   join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                   join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                     dimClient.Id into taskClientJoin
+                   from a in taskClientJoin.DefaultIfEmpty()
+                   let startTime = factTask.StartTime ?? DateTime.Now
+                   let endTime = factTask.EndTime ?? DateTime.Now
+                   select new DT.Task {
+                     Id = factTask.TaskId,
+                     JobId = factTask.JobId,
+                     JobName = dimJob.JobName,
+                     TotalTime = (long)(endTime - startTime).TotalSeconds,
+                     CalculatingTime = factTask.CalculatingTime,
+                     WaitingTime = factTask.WaitingTime,
+                     TransferTime = factTask.TransferTime,
+                     InitialWaitingTime = factTask.InitialWaitingTime,
+                     NumCalculationRuns = factTask.NumCalculationRuns,
+                     NumRetries = factTask.NumRetries,
+                     CoresRequired = factTask.CoresRequired,
+                     MemoryRequired = factTask.MemoryRequired,
+                     Priority = factTask.Priority,
+                     State = factTask.TaskState.ToString(),
+                     LastClientId = factTask.LastClientId,
+                     LastClientName = a != null ? a.Name : string.Empty,
+                     UserId = dimJob.UserId,
+                     UserName = dimJob.UserName,
+                     StartTime = factTask.StartTime,
+                     EndTime = factTask.EndTime,
+                     Exception = factTask.Exception
+                   })
+            .Skip((page - 1) * size)
+            .Take(size)
+            .ToList()
+        };
+      });
     }
 
@@ -109,72 +108,70 @@
     public DT.TaskPage GetTasksByClientId(Guid id, int page, int size, IEnumerable<string> states, Guid userId = default(Guid)) {
       bool isAdministrator = User.IsInRole(HiveRoles.Administrator);
-      using (var pm = PersistenceManager) {
-        var dimJobDao = pm.DimJobDao;
-        var dimClientDao = pm.DimClientDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var tasks = factTaskDao.GetByClientId(id).Where(x => states.Contains(x.TaskState.ToString()));
-          if (userId != Guid.Empty) {
-            tasks = tasks.Where(x => x.DimJob.UserId == userId);
-          }
-          return new DT.TaskPage {
-            TotalTasks = tasks.Count(),
-            Tasks = (from factTask in tasks
-                     join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
-                     join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
-                       dimClient.Id into taskClientJoin
-                     from a in taskClientJoin.DefaultIfEmpty()
-                     let startTime = factTask.StartTime ?? DateTime.Now
-                     let endTime = factTask.EndTime ?? DateTime.Now
-                     select new DT.Task {
-                       Id = isAdministrator ? factTask.TaskId : default(Guid),
-                       JobId = isAdministrator ? factTask.JobId : default(Guid),
-                       JobName = isAdministrator ? dimJob.JobName : string.Empty,
-                       TotalTime = (long)(endTime - startTime).TotalSeconds,
-                       CalculatingTime = factTask.CalculatingTime,
-                       WaitingTime = factTask.WaitingTime,
-                       TransferTime = factTask.TransferTime,
-                       InitialWaitingTime = factTask.InitialWaitingTime,
-                       NumCalculationRuns = factTask.NumCalculationRuns,
-                       NumRetries = factTask.NumRetries,
-                       CoresRequired = factTask.CoresRequired,
-                       MemoryRequired = factTask.MemoryRequired,
-                       Priority = factTask.Priority,
-                       State = factTask.TaskState.ToString(),
-                       LastClientId = factTask.LastClientId,
-                       LastClientName = a != null ? a.Name : string.Empty,
-                       UserId = isAdministrator ? dimJob.UserId : default(Guid),
-                       UserName = isAdministrator ? dimJob.UserName : string.Empty,
-                       StartTime = factTask.StartTime,
-                       EndTime = factTask.EndTime,
-                       Exception = isAdministrator ? factTask.Exception : string.Empty
-                     })
-                  .OrderByDescending(x => x.EndTime ?? DateTime.MaxValue)
-                  .Skip((page - 1) * size)
-                  .Take(size)
-                  .ToList()
-          };
-        });
-      }
+      var pm = PersistenceManager;
+      var dimJobDao = pm.DimJobDao;
+      var dimClientDao = pm.DimClientDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var tasks = factTaskDao.GetByClientId(id).Where(x => states.Contains(x.TaskState.ToString()));
+        if (userId != Guid.Empty) {
+          tasks = tasks.Where(x => x.DimJob.UserId == userId);
+        }
+        return new DT.TaskPage {
+          TotalTasks = tasks.Count(),
+          Tasks = (from factTask in tasks
+                   join dimJob in dimJobDao.GetAll() on factTask.JobId equals dimJob.JobId
+                   join dimClient in dimClientDao.GetAll() on factTask.LastClientId equals
+                     dimClient.Id into taskClientJoin
+                   from a in taskClientJoin.DefaultIfEmpty()
+                   let startTime = factTask.StartTime ?? DateTime.Now
+                   let endTime = factTask.EndTime ?? DateTime.Now
+                   select new DT.Task {
+                     Id = isAdministrator ? factTask.TaskId : default(Guid),
+                     JobId = isAdministrator ? factTask.JobId : default(Guid),
+                     JobName = isAdministrator ? dimJob.JobName : string.Empty,
+                     TotalTime = (long)(endTime - startTime).TotalSeconds,
+                     CalculatingTime = factTask.CalculatingTime,
+                     WaitingTime = factTask.WaitingTime,
+                     TransferTime = factTask.TransferTime,
+                     InitialWaitingTime = factTask.InitialWaitingTime,
+                     NumCalculationRuns = factTask.NumCalculationRuns,
+                     NumRetries = factTask.NumRetries,
+                     CoresRequired = factTask.CoresRequired,
+                     MemoryRequired = factTask.MemoryRequired,
+                     Priority = factTask.Priority,
+                     State = factTask.TaskState.ToString(),
+                     LastClientId = factTask.LastClientId,
+                     LastClientName = a != null ? a.Name : string.Empty,
+                     UserId = isAdministrator ? dimJob.UserId : default(Guid),
+                     UserName = isAdministrator ? dimJob.UserName : string.Empty,
+                     StartTime = factTask.StartTime,
+                     EndTime = factTask.EndTime,
+                     Exception = isAdministrator ? factTask.Exception : string.Empty
+                   })
+                .OrderByDescending(x => x.EndTime ?? DateTime.MaxValue)
+                .Skip((page - 1) * size)
+                .Take(size)
+                .ToList()
+        };
+      });
     }
 
     public HttpResponseMessage GetTaskDataById(Guid id) {
-      using (var pm = PersistenceManager) {
-        var taskDataDao = pm.TaskDataDao;
-        return pm.UseTransaction(() => {
-          var taskData = taskDataDao.GetById(id);
-          if (taskData == null)
-            return new HttpResponseMessage(HttpStatusCode.NotFound);
-          HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
-          var stream = new MemoryStream(taskData.Data);
-          result.Content = new StreamContent(stream);
-          result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
-          result.Content.Headers.ContentDisposition =
-            new ContentDispositionHeaderValue("attachment") {
-              FileName = string.Format("{0}.hl", id)
-            };
-          return result;
-        });
-      }
+      var pm = PersistenceManager;
+      var taskDataDao = pm.TaskDataDao;
+      return pm.UseTransaction(() => {
+        var taskData = taskDataDao.GetById(id);
+        if (taskData == null)
+          return new HttpResponseMessage(HttpStatusCode.NotFound);
+        HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
+        var stream = new MemoryStream(taskData.Data);
+        result.Content = new StreamContent(stream);
+        result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
+        result.Content.Headers.ContentDisposition =
+          new ContentDispositionHeaderValue("attachment") {
+            FileName = string.Format("{0}.hl", id)
+          };
+        return result;
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/UserController.cs	(revision 12858)
@@ -37,36 +37,34 @@
 
     public IEnumerable<DT.User> GetUsers() {
-      using (var pm = PersistenceManager) {
-        var dimUserDao = pm.DimUserDao;
-        return pm.UseTransaction(() => {
-          return dimUserDao.GetAll().Select(x => new DT.User {
-            Id = x.UserId,
-            Name = x.Name
-          }).ToList();
-        });
-      }
+      var pm = PersistenceManager;
+      var dimUserDao = pm.DimUserDao;
+      return pm.UseTransaction(() => {
+        return dimUserDao.GetAll().Select(x => new DT.User {
+          Id = x.UserId,
+          Name = x.Name
+        }).ToList();
+      });
     }
 
     public DT.UserDetails GetUser(Guid id) {
-      using (var pm = PersistenceManager) {
-        var dimUserDao = pm.DimUserDao;
-        var factTaskDao = pm.FactTaskDao;
-        return pm.UseTransaction(() => {
-          var user = dimUserDao.GetById(id);
-          if (user != null) {
-            return new DT.UserDetails {
-              Id = user.UserId,
-              Name = user.Name,
-              TasksStates = factTaskDao.GetByUserId(id)
-                            .GroupBy(x => x.TaskState)
-                            .Select(x => new DT.TaskStateCount {
-                              State = x.Key.ToString(),
-                              Count = x.Count()
-                            }).ToList()
-            };
-          }
-          return null;
-        });
-      }
+      var pm = PersistenceManager;
+      var dimUserDao = pm.DimUserDao;
+      var factTaskDao = pm.FactTaskDao;
+      return pm.UseTransaction(() => {
+        var user = dimUserDao.GetById(id);
+        if (user != null) {
+          return new DT.UserDetails {
+            Id = user.UserId,
+            Name = user.Name,
+            TasksStates = factTaskDao.GetByUserId(id)
+                          .GroupBy(x => x.TaskState)
+                          .Select(x => new DT.TaskStateCount {
+                            State = x.Key.ToString(),
+                            Count = x.Count()
+                          }).ToList()
+          };
+        }
+        return null;
+      });
     }
   }
Index: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs	(revision 12857)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs	(revision 12858)
@@ -99,53 +99,52 @@
 
     public DT.Status GetStatus() {
-      using (var pm = PersistenceManager) {
-        var slaveDao = pm.SlaveDao;
-        var onlineSlaves = pm.UseTransaction(() => slaveDao.GetOnlineSlaves().ToList());
-        var activeSlaves = onlineSlaves.Where(s => s.IsAllowedToCalculate).ToList();
-        var calculatingSlaves = activeSlaves.Where(s => s.SlaveState == SlaveState.Calculating).ToList();
-        int totalCores = onlineSlaves.Sum(s => s.Cores ?? 0);
-        int totalMemory = onlineSlaves.Sum(s => s.Memory ?? 0);
-        return new DT.Status {
-          CoreStatus = new DT.CoreStatus {
-            TotalCores = totalCores,
-            UsedCores = totalCores - onlineSlaves.Sum(s => s.FreeCores ?? 0),
-            ActiveCores = activeSlaves.Sum(s => s.Cores ?? 0),
-            CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0)
+      var pm = PersistenceManager;
+      var slaveDao = pm.SlaveDao;
+      var onlineSlaves = pm.UseTransaction(() => slaveDao.GetOnlineSlaves().ToList());
+      var activeSlaves = onlineSlaves.Where(s => s.IsAllowedToCalculate).ToList();
+      var calculatingSlaves = activeSlaves.Where(s => s.SlaveState == SlaveState.Calculating).ToList();
+      int totalCores = onlineSlaves.Sum(s => s.Cores ?? 0);
+      int totalMemory = onlineSlaves.Sum(s => s.Memory ?? 0);
+      return new DT.Status {
+        CoreStatus = new DT.CoreStatus {
+          TotalCores = totalCores,
+          UsedCores = totalCores - onlineSlaves.Sum(s => s.FreeCores ?? 0),
+          ActiveCores = activeSlaves.Sum(s => s.Cores ?? 0),
+          CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0)
+        },
+        CpuUtilizationStatus = new DT.CpuUtilizationStatus {
+          TotalCpuUtilization = onlineSlaves.Any()
+                                ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2)
+                                : 0.0,
+          ActiveCpuUtilization = activeSlaves.Any()
+                                 ? Math.Round(activeSlaves.Average(s => s.CpuUtilization), 2)
+                                 : 0.0,
+          CalculatingCpuUtilization = calculatingSlaves.Any()
+                                      ? Math.Round(calculatingSlaves.Average(s => s.CpuUtilization), 2)
+                                      : 0.0
+        },
+        MemoryStatus = new DT.MemoryStatus {
+          TotalMemory = totalMemory,
+          UsedMemory = totalMemory - onlineSlaves.Sum(s => s.FreeMemory ?? 0),
+          ActiveMemory = activeSlaves.Sum(s => s.Memory ?? 0),
+          CalculatingMemory = calculatingSlaves.Sum(s => s.Memory ?? 0) - calculatingSlaves.Sum(s => s.FreeMemory ?? 0)
+        },
+        TimeStatus = GetTimeStatus(pm),
+        TasksStatus = GetTaskStatus(pm),
+        SlavesStatus = onlineSlaves.Select(x => new DT.SlaveStatus {
+          Slave = new DT.Slave {
+            Id = x.ResourceId.ToString(),
+            Name = x.Name
           },
-          CpuUtilizationStatus = new DT.CpuUtilizationStatus {
-            TotalCpuUtilization = onlineSlaves.Any()
-                                  ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2)
-                                  : 0.0,
-            ActiveCpuUtilization = activeSlaves.Any()
-                                   ? Math.Round(activeSlaves.Average(s => s.CpuUtilization), 2)
-                                   : 0.0,
-            CalculatingCpuUtilization = calculatingSlaves.Any()
-                                        ? Math.Round(calculatingSlaves.Average(s => s.CpuUtilization), 2)
-                                        : 0.0
-          },
-          MemoryStatus = new DT.MemoryStatus {
-            TotalMemory = totalMemory,
-            UsedMemory = totalMemory - onlineSlaves.Sum(s => s.FreeMemory ?? 0),
-            ActiveMemory = activeSlaves.Sum(s => s.Memory ?? 0),
-            CalculatingMemory = calculatingSlaves.Sum(s => s.Memory ?? 0) - calculatingSlaves.Sum(s => s.FreeMemory ?? 0)
-          },
-          TimeStatus = GetTimeStatus(pm),
-          TasksStatus = GetTaskStatus(pm),
-          SlavesStatus = onlineSlaves.Select(x => new DT.SlaveStatus {
-            Slave = new DT.Slave {
-              Id = x.ResourceId.ToString(),
-              Name = x.Name
-            },
-            CpuUtilization = x.CpuUtilization,
-            Cores = x.Cores ?? 0,
-            FreeCores = x.FreeCores ?? 0,
-            Memory = x.Memory ?? 0,
-            FreeMemory = x.FreeMemory ?? 0,
-            IsAllowedToCalculate = x.IsAllowedToCalculate,
-            State = x.SlaveState.ToString()
-          }).OrderBy(x => x.Slave.Name),
-          Timestamp = JavascriptUtils.ToTimestamp(DateTime.Now)
-        };
-      }
+          CpuUtilization = x.CpuUtilization,
+          Cores = x.Cores ?? 0,
+          FreeCores = x.FreeCores ?? 0,
+          Memory = x.Memory ?? 0,
+          FreeMemory = x.FreeMemory ?? 0,
+          IsAllowedToCalculate = x.IsAllowedToCalculate,
+          State = x.SlaveState.ToString()
+        }).OrderBy(x => x.Slave.Name),
+        Timestamp = JavascriptUtils.ToTimestamp(DateTime.Now)
+      };
     }
 
@@ -158,56 +157,55 @@
         increment += 5;
       }
-      using (var pm = PersistenceManager) {
-        var factClientInfoDao = pm.FactClientInfoDao;
-        var clientInfos = pm.UseTransaction(() => {
-          return factClientInfoDao.GetAll()
-            .Where(s => s.Time >= start
-                        && s.Time <= end
-                        && s.SlaveState != SlaveState.Offline)
-            .OrderBy(s => s.Time)
-            .GroupBy(s => s.Time)
-            .Select(x => new {
-              Timestamp = x.Key,
-              TotalCores = x.Sum(y => y.NumTotalCores),
-              UsedCores = x.Sum(y => y.NumUsedCores),
-              TotalMemory = x.Sum(y => y.TotalMemory),
-              UsedMemory = x.Sum(y => y.UsedMemory),
-              CpuUtilization = x.Where(y => y.IsAllowedToCalculate).Average(y => y.CpuUtilization)
-            })
-            .ToList();
-        });
-        var statusList = new List<DT.Status>();
-        var e = clientInfos.GetEnumerator();
-        do {
-          var status = new DT.Status {
-            CoreStatus = new DT.CoreStatus(),
-            CpuUtilizationStatus = new DT.CpuUtilizationStatus(),
-            MemoryStatus = new DT.MemoryStatus()
-          };
-          int i = 0;
-          DateTime lastTimestamp = DateTime.Now;
-          while (e.MoveNext()) {
-            var clientInfo = e.Current;
-            status.CoreStatus.TotalCores += clientInfo.TotalCores;
-            status.CoreStatus.UsedCores += clientInfo.UsedCores;
-            status.MemoryStatus.TotalMemory += clientInfo.TotalMemory;
-            status.MemoryStatus.UsedMemory += clientInfo.UsedMemory;
-            status.CpuUtilizationStatus.TotalCpuUtilization += clientInfo.CpuUtilization;
-            lastTimestamp = clientInfo.Timestamp;
-            i++;
-            if (i >= increment)
-              break;
-          }
-          if (i <= 0) continue;
-          status.Timestamp = JavascriptUtils.ToTimestamp(lastTimestamp);
-          status.CoreStatus.TotalCores /= i;
-          status.CoreStatus.UsedCores /= i;
-          status.MemoryStatus.TotalMemory /= i;
-          status.MemoryStatus.UsedMemory /= i;
-          status.CpuUtilizationStatus.TotalCpuUtilization /= i;
-          statusList.Add(status);
-        } while (e.Current != null);
-        return statusList;
-      }
+      var pm = PersistenceManager;
+      var factClientInfoDao = pm.FactClientInfoDao;
+      var clientInfos = pm.UseTransaction(() => {
+        return factClientInfoDao.GetAll()
+          .Where(s => s.Time >= start
+                      && s.Time <= end
+                      && s.SlaveState != SlaveState.Offline)
+          .OrderBy(s => s.Time)
+          .GroupBy(s => s.Time)
+          .Select(x => new {
+            Timestamp = x.Key,
+            TotalCores = x.Sum(y => y.NumTotalCores),
+            UsedCores = x.Sum(y => y.NumUsedCores),
+            TotalMemory = x.Sum(y => y.TotalMemory),
+            UsedMemory = x.Sum(y => y.UsedMemory),
+            CpuUtilization = x.Where(y => y.IsAllowedToCalculate).Average(y => y.CpuUtilization)
+          })
+          .ToList();
+      });
+      var statusList = new List<DT.Status>();
+      var e = clientInfos.GetEnumerator();
+      do {
+        var status = new DT.Status {
+          CoreStatus = new DT.CoreStatus(),
+          CpuUtilizationStatus = new DT.CpuUtilizationStatus(),
+          MemoryStatus = new DT.MemoryStatus()
+        };
+        int i = 0;
+        DateTime lastTimestamp = DateTime.Now;
+        while (e.MoveNext()) {
+          var clientInfo = e.Current;
+          status.CoreStatus.TotalCores += clientInfo.TotalCores;
+          status.CoreStatus.UsedCores += clientInfo.UsedCores;
+          status.MemoryStatus.TotalMemory += clientInfo.TotalMemory;
+          status.MemoryStatus.UsedMemory += clientInfo.UsedMemory;
+          status.CpuUtilizationStatus.TotalCpuUtilization += clientInfo.CpuUtilization;
+          lastTimestamp = clientInfo.Timestamp;
+          i++;
+          if (i >= increment)
+            break;
+        }
+        if (i <= 0) continue;
+        status.Timestamp = JavascriptUtils.ToTimestamp(lastTimestamp);
+        status.CoreStatus.TotalCores /= i;
+        status.CoreStatus.UsedCores /= i;
+        status.MemoryStatus.TotalMemory /= i;
+        status.MemoryStatus.UsedMemory /= i;
+        status.CpuUtilizationStatus.TotalCpuUtilization /= i;
+        statusList.Add(status);
+      } while (e.Current != null);
+      return statusList;
     }
 
