Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/App.config
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/App.config	(revision 9526)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/App.config	(revision 9527)
@@ -1,3 +1,3 @@
-﻿<?xml version="1.0"?>
+<?xml version="1.0"?>
 <configuration>
   <configSections>
@@ -6,7 +6,7 @@
     </sectionGroup>
   </configSections>
-
   <appSettings>
     <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
+    <add key="ClientSettingsProvider.ServiceUri" value="" />
   </appSettings>
   <applicationSettings>
@@ -21,8 +21,6 @@
   </applicationSettings>
   <connectionStrings>
-    <add name="HeuristicLab.Authentication" connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication"/>
-    <add name="HeuristicLab.Services.Hive.DataAccess.Settings.HeuristicLab_Hive_LinqConnectionString"
-       connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.3;Integrated Security=True;"
-       providerName="System.Data.SqlClient" />
+    <add name="HeuristicLab.Authentication" connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication" />
+    <add name="HeuristicLab.Services.Hive.DataAccess.Settings.HeuristicLab_Hive_LinqConnectionString" connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.3;Integrated Security=True;" providerName="System.Data.SqlClient" />
   </connectionStrings>
   <system.web>
@@ -30,30 +28,31 @@
     <compilation debug="true" targetFramework="4.0">
       <assemblies>
-        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       </assemblies>
     </compilation>
-    <membership>
+    <membership defaultProvider="ClientAuthenticationMembershipProvider">
       <providers>
-        <clear/>
-        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="HeuristicLab.Authentication"/>
+        <clear />
+        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="HeuristicLab.Authentication" />
+        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
       </providers>
     </membership>
-    <roleManager enabled="true">
+    <roleManager enabled="true" defaultProvider="ClientRoleProvider">
       <providers>
-        <clear/>
-        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication"/>
+        <clear />
+        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication" />
+        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
       </providers>
     </roleManager>
     <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
       <controls>
-        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
-         assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
       </controls>
     </pages>
-    <httpRuntime maxRequestLength="1048576"/>
+    <httpRuntime maxRequestLength="1048576" />
   </system.web>
   <system.serviceModel>
     <diagnostics performanceCounters="All">
-      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
+      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
     </diagnostics>
     <bindings>
@@ -62,6 +61,6 @@
           <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
           <security mode="Message">
-            <transport clientCredentialType="Certificate"/>
-            <message clientCredentialType="UserName"/>
+            <transport clientCredentialType="Certificate" />
+            <message clientCredentialType="UserName" />
           </security>
         </binding>
@@ -72,15 +71,15 @@
         <behavior name="ServiceBehaviour_IHiveService">
           <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
-          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
+          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
           <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
-          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
-          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider"/>
+          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
+          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" />
           <serviceCredentials>
-            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName"/>
-            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
+            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" />
+            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider" />
           </serviceCredentials>
-          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" messageAuthenticationAuditLevel="SuccessOrFailure"/>
-          <serviceThrottling maxConcurrentCalls="100"/>
-          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
+          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" messageAuthenticationAuditLevel="SuccessOrFailure" />
+          <serviceThrottling maxConcurrentCalls="100" />
+          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         </behavior>
       </serviceBehaviors>
@@ -88,9 +87,9 @@
     <services>
       <service behaviorConfiguration="ServiceBehaviour_IHiveService" name="HeuristicLab.Services.Hive.HiveService">
-        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexEndpoint" contract="IMetadataExchange"/>
-        <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" name="WSHttpBinding_IHiveService" contract="HeuristicLab.Services.Hive.ServiceContracts.IHiveService"/>
+        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexEndpoint" contract="IMetadataExchange" />
+        <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" name="WSHttpBinding_IHiveService" contract="HeuristicLab.Services.Hive.ServiceContracts.IHiveService" />
       </service>
     </services>
-    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
+    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
   </system.serviceModel>
   <system.webServer>
@@ -98,7 +97,9 @@
     <handlers>
       <remove name="ChartImageHandler" />
-      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
-       path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
     </handlers>
   </system.webServer>
+  <startup>
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+  </startup>
 </configuration>
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/HeuristicLab.Services.Hive.SelfHost-3.3.csproj
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/HeuristicLab.Services.Hive.SelfHost-3.3.csproj	(revision 9526)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/HeuristicLab.Services.Hive.SelfHost-3.3.csproj	(revision 9527)
@@ -6,10 +6,11 @@
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProjectGuid>{DAACE3EB-5D88-419D-9EEC-5707E273491A}</ProjectGuid>
-    <OutputType>Exe</OutputType>
+    <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>HeuristicLab.Services.Hive.SelfHost</RootNamespace>
     <AssemblyName>HeuristicLab.Services.Hive.SelfHost-3.3</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
@@ -24,7 +25,7 @@
     <ApplicationRevision>0</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -37,4 +38,5 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -46,11 +48,27 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Web.Extensions" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="JanitorActivatorForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="JanitorActivatorForm.Designer.cs">
+      <DependentUpon>JanitorActivatorForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="Program.cs" />
     <None Include="App.config" />
@@ -86,4 +104,9 @@
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="JanitorActivatorForm.resx">
+      <DependentUpon>JanitorActivatorForm.cs</DependentUpon>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.Designer.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.Designer.cs	(revision 9527)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.Designer.cs	(revision 9527)
@@ -0,0 +1,171 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Services.Hive.SelfHost {
+  partial class JanitorActivatorForm {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.activateJanitorButton = new System.Windows.Forms.Button();
+      this.outputTextbox = new System.Windows.Forms.TextBox();
+      this.runServiceButton = new System.Windows.Forms.Button();
+      this.janitorFrequency = new System.Windows.Forms.TrackBar();
+      this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
+      this.runCleanupButton = new System.Windows.Forms.Button();
+      this.frequencyTextBox = new System.Windows.Forms.TextBox();
+      this.generateStatisticsButton = new System.Windows.Forms.Button();
+      ((System.ComponentModel.ISupportInitialize)(this.janitorFrequency)).BeginInit();
+      this.flowLayoutPanel1.SuspendLayout();
+      this.SuspendLayout();
+      // 
+      // activateJanitorButton
+      // 
+      this.activateJanitorButton.Location = new System.Drawing.Point(118, 3);
+      this.activateJanitorButton.Name = "activateJanitorButton";
+      this.activateJanitorButton.Size = new System.Drawing.Size(115, 23);
+      this.activateJanitorButton.TabIndex = 0;
+      this.activateJanitorButton.Text = "Start Janitor";
+      this.activateJanitorButton.UseVisualStyleBackColor = true;
+      this.activateJanitorButton.Click += new System.EventHandler(this.activateJanitorButton_Click);
+      // 
+      // outputTextbox
+      // 
+      this.outputTextbox.Dock = System.Windows.Forms.DockStyle.Bottom;
+      this.outputTextbox.Location = new System.Drawing.Point(0, 89);
+      this.outputTextbox.Multiline = true;
+      this.outputTextbox.Name = "outputTextbox";
+      this.outputTextbox.Size = new System.Drawing.Size(462, 429);
+      this.outputTextbox.TabIndex = 1;
+      // 
+      // runServiceButton
+      // 
+      this.runServiceButton.Location = new System.Drawing.Point(3, 3);
+      this.runServiceButton.Name = "runServiceButton";
+      this.runServiceButton.Size = new System.Drawing.Size(109, 23);
+      this.runServiceButton.TabIndex = 2;
+      this.runServiceButton.Text = "Start Service";
+      this.runServiceButton.UseVisualStyleBackColor = true;
+      this.runServiceButton.Click += new System.EventHandler(this.runServiceButton_Click);
+      // 
+      // janitorFrequency
+      // 
+      this.janitorFrequency.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.janitorFrequency.Location = new System.Drawing.Point(3, 32);
+      this.janitorFrequency.Maximum = 600;
+      this.janitorFrequency.Name = "janitorFrequency";
+      this.janitorFrequency.Size = new System.Drawing.Size(373, 42);
+      this.janitorFrequency.SmallChange = 10;
+      this.janitorFrequency.TabIndex = 3;
+      this.janitorFrequency.TickFrequency = 60;
+      this.janitorFrequency.Value = 120;
+      this.janitorFrequency.ValueChanged += new System.EventHandler(this.janitorFrequency_ValueChanged);
+      // 
+      // flowLayoutPanel1
+      // 
+      this.flowLayoutPanel1.Controls.Add(this.runServiceButton);
+      this.flowLayoutPanel1.Controls.Add(this.activateJanitorButton);
+      this.flowLayoutPanel1.Controls.Add(this.runCleanupButton);
+      this.flowLayoutPanel1.Controls.Add(this.generateStatisticsButton);
+      this.flowLayoutPanel1.Controls.Add(this.janitorFrequency);
+      this.flowLayoutPanel1.Controls.Add(this.frequencyTextBox);
+      this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
+      this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
+      this.flowLayoutPanel1.Name = "flowLayoutPanel1";
+      this.flowLayoutPanel1.Size = new System.Drawing.Size(462, 83);
+      this.flowLayoutPanel1.TabIndex = 4;
+      // 
+      // runCleanupButton
+      // 
+      this.runCleanupButton.Location = new System.Drawing.Point(239, 3);
+      this.runCleanupButton.Name = "runCleanupButton";
+      this.runCleanupButton.Size = new System.Drawing.Size(101, 23);
+      this.runCleanupButton.TabIndex = 4;
+      this.runCleanupButton.Text = "Run Cleanup";
+      this.runCleanupButton.UseVisualStyleBackColor = true;
+      this.runCleanupButton.Click += new System.EventHandler(this.runJanitorButton_Click);
+      // 
+      // frequencyTextBox
+      // 
+      this.frequencyTextBox.Location = new System.Drawing.Point(382, 32);
+      this.frequencyTextBox.Name = "frequencyTextBox";
+      this.frequencyTextBox.Size = new System.Drawing.Size(68, 20);
+      this.frequencyTextBox.TabIndex = 5;
+      // 
+      // generateStatisticsButton
+      // 
+      this.generateStatisticsButton.Location = new System.Drawing.Point(346, 3);
+      this.generateStatisticsButton.Name = "generateStatisticsButton";
+      this.generateStatisticsButton.Size = new System.Drawing.Size(106, 23);
+      this.generateStatisticsButton.TabIndex = 6;
+      this.generateStatisticsButton.Text = "Generate Statistics";
+      this.generateStatisticsButton.UseVisualStyleBackColor = true;
+      this.generateStatisticsButton.Click += new System.EventHandler(this.generateStatisticsButton_Click);
+      // 
+      // JanitorActivatorForm
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.ClientSize = new System.Drawing.Size(462, 518);
+      this.Controls.Add(this.flowLayoutPanel1);
+      this.Controls.Add(this.outputTextbox);
+      this.Name = "JanitorActivatorForm";
+      this.Text = "Janitor Activator";
+      ((System.ComponentModel.ISupportInitialize)(this.janitorFrequency)).EndInit();
+      this.flowLayoutPanel1.ResumeLayout(false);
+      this.flowLayoutPanel1.PerformLayout();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Button activateJanitorButton;
+    private System.Windows.Forms.TextBox outputTextbox;
+    private System.Windows.Forms.Button runServiceButton;
+    private System.Windows.Forms.TrackBar janitorFrequency;
+    private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
+    private System.Windows.Forms.Button runCleanupButton;
+    private System.Windows.Forms.TextBox frequencyTextBox;
+    private System.Windows.Forms.Button generateStatisticsButton;
+  }
+}
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.cs	(revision 9527)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.cs	(revision 9527)
@@ -0,0 +1,174 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.ServiceModel;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HeuristicLab.Services.Hive.SelfHost {
+  public partial class JanitorActivatorForm : Form {
+    private static readonly Uri BaseAddress = new Uri(@"http://localhost/Hive-3.3/HiveService.svc");
+
+    private IEventManager eventManager {
+      get { return ServiceLocator.Instance.EventManager; }
+    }
+
+    private IStatisticsGenerator statisticsGenerator {
+      get { return ServiceLocator.Instance.StatisticsGenerator; }
+    }
+
+    private Thread janitorThread;
+
+    private bool janitorRunning;
+
+    private readonly EventWaitHandle janitorWaitHandle;
+
+    private readonly ServiceHost host;
+
+    private bool serviceRunning;
+
+    public JanitorActivatorForm() {
+      InitializeComponent();
+      janitorFrequency_ValueChanged(null, null);
+
+      janitorWaitHandle = new AutoResetEvent(false);
+
+      host = new ServiceHost(typeof(HiveService), BaseAddress);
+    }
+
+    private void activateJanitorButton_Click(object sender, EventArgs e) {
+      activateJanitorButton.Enabled = false;
+
+      try {
+        janitorRunning = !janitorRunning;
+
+        if (janitorRunning && janitorThread == null) {
+          janitorThread = new Thread(RunEventManager) {
+            IsBackground = true
+          };
+          janitorThread.Start();
+        }
+
+        janitorWaitHandle.Set();
+      }
+      catch (Exception exc) {
+        WriteLine(exc.Message);
+        WriteLine(exc.StackTrace);
+        janitorRunning = false;
+        janitorThread = null;
+      }
+
+      WriteLine(janitorRunning ? "Activated Janitor" : "Janitor deactivated");
+
+      activateJanitorButton.Text = janitorRunning ? "Stop Janitor" : "Start Janitor";
+
+      activateJanitorButton.Enabled = true;
+    }
+
+    private void RunEventManager() {
+      while (janitorRunning) {
+        int frequency = 0;
+        Invoke(new Action(() => frequency = janitorFrequency.Value));
+
+        janitorWaitHandle.WaitOne(frequency * 1000);
+
+        WriteLine("Run Janitor");
+        lock (eventManager) {
+          eventManager.Cleanup();
+        }
+        lock (statisticsGenerator) {
+          statisticsGenerator.GenerateStatistics();
+        }
+      }
+      janitorThread = null;
+    }
+
+    private async void runServiceButton_Click(object sender, EventArgs e) {
+      runServiceButton.Enabled = false;
+
+      try {
+        await StartService();
+
+        WriteLine(serviceRunning ? "Service is ready at " + BaseAddress : "Service is closed");
+      }
+      catch (Exception exc) {
+        WriteLine(exc.Message);
+        WriteLine(exc.StackTrace);
+        serviceRunning = false;
+      }
+
+      runServiceButton.Text = serviceRunning ? "Stop Service" : "Start Service";
+      runServiceButton.Enabled = true;
+    }
+
+    private Task StartService() {
+      return Task.Run(() => {
+        serviceRunning = !serviceRunning;
+
+        if (serviceRunning) {
+          host.Open();
+        } else {
+          host.Close();
+        }
+      });
+    }
+
+    private async void runJanitorButton_Click(object sender, EventArgs e) {
+      runCleanupButton.Enabled = false;
+
+      await Task.Run(() => {
+        lock (eventManager) {
+          WriteLine("Run Cleanup");
+          eventManager.Cleanup();
+        }
+      });
+
+      runCleanupButton.Enabled = true;
+    }
+
+    private async void generateStatisticsButton_Click(object sender, EventArgs e) {
+      generateStatisticsButton.Enabled = false;
+
+      await Task.Run(() => {
+        lock (eventManager) {
+          WriteLine("Generate Statistics");
+          statisticsGenerator.GenerateStatistics();
+        }
+      });
+
+      generateStatisticsButton.Enabled = true;
+    }
+
+    private void janitorFrequency_ValueChanged(object sender, EventArgs e) {
+      frequencyTextBox.Text = string.Format("{0} sek", janitorFrequency.Value);
+    }
+
+    private void WriteLine(string msg) {
+      if (InvokeRequired) {
+        Invoke(new Action<string>(WriteLine), msg);
+        return;
+      }
+      outputTextbox.AppendText(string.Format("{0}: {1}{2}", DateTime.Now.ToLongTimeString(), msg, Environment.NewLine));
+    }
+  }
+}
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.resx
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.resx	(revision 9527)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/JanitorActivatorForm.resx	(revision 9527)
@@ -0,0 +1,120 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
Index: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/Program.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/Program.cs	(revision 9526)
+++ branches/HiveStatistics/sources/HeuristicLab.Services.Hive.SelfHost/3.3/Program.cs	(revision 9527)
@@ -21,20 +21,11 @@
 
 using System;
-using System.ServiceModel;
+using System.Windows.Forms;
+
 namespace HeuristicLab.Services.Hive.SelfHost {
-  class Program {
-    static void Main(string[] args) {
-      var baseAdress = new Uri(@"http://localhost/Hive-3.3/HiveService.svc");
-
-      using (var host = new ServiceHost(typeof(HiveService), baseAdress)) {
-        host.Open();
-
-        Console.WriteLine("Service is ready at {0}", baseAdress);
-        Console.WriteLine("Press <Enter> to stop the service.");
-
-        Console.ReadLine();
-
-        host.Close();
-      }
+  internal class Program {
+    [STAThread]
+    private static void Main(string[] args) {
+      Application.Run(new JanitorActivatorForm());
     }
   }
