Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision cd4a6e84fc65152a21053ba13c6d87bca6e724ae)
+++ src/Fragmentation/Automation/Makefile.am	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -13,4 +13,6 @@
 
 servers11n_SOURCES = \
+  atexit.cpp \
+  atexit.hpp \
   Connection.hpp \
   FragmentJob.cpp \
@@ -18,5 +20,5 @@
   FragmentScheduler.cpp \
   FragmentScheduler.hpp \
-  server.cpp
+  Server.cpp
 servers11n_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
 servers11n_CXXFLAGS = $(AM_CPPFLAGS)
Index: src/Fragmentation/Automation/Server.cpp
===================================================================
--- src/Fragmentation/Automation/Server.cpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
+++ src/Fragmentation/Automation/Server.cpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -0,0 +1,66 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * \file Server.cpp
+ *
+ * This file strongly follows the Serialization example from the boost::asio
+ * library (see server.cpp)
+ *
+ *  Created on: Oct 21, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <boost/lexical_cast.hpp>
+#include <iostream>
+
+#include "atexit.hpp"
+#include "CodePatterns/Info.hpp"
+#include "FragmentScheduler.hpp"
+
+
+int main(int argc, char* argv[])
+{
+  // from this moment on, we need to be sure to deinitialize in the correct order
+  // this is handled by the cleanup function
+  atexit(cleanUp);
+
+  try
+  {
+    // Check command line arguments.
+    if (argc != 2)
+    {
+      std::cerr << "Usage: " << argv[0] << " <port>" << std::endl;
+      return 1;
+    }
+    unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
+    std::cout << "Listening on port " << port << "." << std::endl;
+
+    boost::asio::io_service io_service;
+    FragmentScheduler Server(io_service, port);
+    {
+      Info info("io_service");
+      io_service.run();
+    }
+  }
+  catch (std::exception& e)
+  {
+    std::cerr << e.what() << std::endl;
+  }
+
+  return 0;
+}
Index: src/Fragmentation/Automation/atexit.cpp
===================================================================
--- src/Fragmentation/Automation/atexit.cpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
+++ src/Fragmentation/Automation/atexit.cpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -0,0 +1,36 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * atexit.cpp
+ *
+ *  Created on: Oct 23, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Chronos.hpp"
+#include "CodePatterns/Log.hpp"
+
+/** Cleans all singleton instances in an orderly fashion.
+ * C++ does not guarantee any specific sequence of removal of single instances
+ * which have static/global variables. Some singletons depend on others hence we
+ * acertain a specific ordering here, which is is used via the atexit() hook.
+ */
+void cleanUp()
+{
+  Chronos::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();;
+  Memory::getState();
+}
Index: src/Fragmentation/Automation/atexit.hpp
===================================================================
--- src/Fragmentation/Automation/atexit.hpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
+++ src/Fragmentation/Automation/atexit.hpp	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -0,0 +1,19 @@
+/*
+ * atexit.hpp
+ *
+ *  Created on: Oct 23, 2011
+ *      Author: heber
+ */
+
+#ifndef ATEXIT_HPP_
+#define ATEXIT_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+void cleanUp();
+
+
+#endif /* ATEXIT_HPP_ */
Index: c/Fragmentation/Automation/server.cpp
===================================================================
--- src/Fragmentation/Automation/server.cpp	(revision cd4a6e84fc65152a21053ba13c6d87bca6e724ae)
+++ 	(revision )
@@ -1,39 +1,0 @@
-//
-// server.cpp
-// ~~~~~~~~~~
-//
-// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/asio.hpp>
-#include <boost/lexical_cast.hpp>
-#include <iostream>
-#include "FragmentScheduler.hpp"
-
-
-int main(int argc, char* argv[])
-{
-  try
-  {
-    // Check command line arguments.
-    if (argc != 2)
-    {
-      std::cerr << "Usage: server <port>" << std::endl;
-      return 1;
-    }
-    unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
-
-    boost::asio::io_service io_service;
-    FragmentScheduler server(io_service, port);
-    io_service.run();
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-
-  return 0;
-}
Index: tests/CodeChecks/testsuite-config_h.at
===================================================================
--- tests/CodeChecks/testsuite-config_h.at	(revision cd4a6e84fc65152a21053ba13c6d87bca6e724ae)
+++ tests/CodeChecks/testsuite-config_h.at	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -1,5 +1,5 @@
 AT_SETUP([Checking for present config.h include])
 AT_KEYWORDS([CodeCheck config_h])
-ok="unity.cpp AllActionHeaders.hpp AllActionPython.hpp pugiconfig.hpp pugixml.cpp pugixml.hpp client.cpp server.cpp"
+ok="unity.cpp AllActionHeaders.hpp AllActionPython.hpp pugiconfig.hpp pugixml.cpp pugixml.hpp client.cpp"
 echo `pwd`
 echo "${#ok[*]} are ok to not contain config.h: ${ok[*]}."
Index: tests/CodeChecks/testsuite-memdebug.at
===================================================================
--- tests/CodeChecks/testsuite-memdebug.at	(revision cd4a6e84fc65152a21053ba13c6d87bca6e724ae)
+++ tests/CodeChecks/testsuite-memdebug.at	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -1,5 +1,5 @@
 AT_SETUP([Checking for present MemDebug.hpp include])
 AT_KEYWORDS([CodeCheck MemDebug])
-ok="builder.cpp MemDebug.cpp SubspaceFactorizer.cpp TestRunner.cpp unity.cpp pugixml.cpp client.cpp server.cpp"
+ok="builder.cpp MemDebug.cpp SubspaceFactorizer.cpp TestRunner.cpp unity.cpp pugixml.cpp client.cpp"
 echo `pwd`
 echo "${#ok[*]} are ok to not contain MemDebug.hpp: ${ok[0]} ${ok[1]}."
Index: tests/CodeChecks/testsuite-project-disclaimer.at
===================================================================
--- tests/CodeChecks/testsuite-project-disclaimer.at	(revision cd4a6e84fc65152a21053ba13c6d87bca6e724ae)
+++ tests/CodeChecks/testsuite-project-disclaimer.at	(revision f7f99510d4b31a8e2923b0af4c9fc96e6ef2fa3f)
@@ -1,5 +1,5 @@
 AT_SETUP([Checking for present project disclaimer])
 AT_KEYWORDS([CodeCheck disclaimer])
-ok="unity.cpp pugixml.cpp client.cpp server.cpp"
+ok="unity.cpp pugixml.cpp client.cpp"
 echo `pwd`
 echo "${#ok[*]} are ok to not contain config.h: ${ok[*]}."
