Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision fd4d5e9f6169e6fb4f1b3ebf883388e3bcf11569)
+++ src/Makefile.am	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -446,5 +446,5 @@
 bin_PROGRAMS += Controller PoolWorker Server
 
-Controller_SOURCES = controller.cpp controller_main.hpp controller_AddOn_MPQCCommandJob.cpp
+Controller_SOURCES = controller.cpp controller_main.cpp controller_main.hpp controller_AddOn_MPQCCommandJob.cpp
 Controller_LDFLAGS = $(AM_LDFLAGS)
 Controller_CXXFLAGS = $(AM_CPPFLAGS)
@@ -459,5 +459,5 @@
 	$(BOOST_PROGRAM_OPTIONS_LIBS) $(BOOST_PROGRAM_OPTIONS_LDFLAGS) 
 
-PoolWorker_SOURCES = poolworker.cpp
+PoolWorker_SOURCES = poolworker.cpp poolworker_main.cpp poolworker_main.hpp
 PoolWorker_LDFLAGS = $(AM_LDFLAGS)
 PoolWorker_CXXFLAGS = $(AM_CPPFLAGS)
@@ -470,5 +470,5 @@
 	$(BOOST_PROGRAM_OPTIONS_LIBS) $(BOOST_PROGRAM_OPTIONS_LDFLAGS) 
 
-Server_SOURCES = Server.cpp
+Server_SOURCES = Server.cpp server_main.cpp server_main.hpp
 Server_LDFLAGS = $(AM_LDFLAGS) 
 Server_CXXFLAGS = $(AM_CPPFLAGS)
Index: src/Server.cpp
===================================================================
--- src/Server.cpp	(revision fd4d5e9f6169e6fb4f1b3ebf883388e3bcf11569)
+++ src/Server.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -2,5 +2,5 @@
  * Project: MoleCuilder
  * Description: creates and alters molecular systems
- * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
  */
@@ -9,8 +9,5 @@
  * \file Server.cpp
  *
- * This file strongly follows the Serialization example from the boost::asio
- * library (see server.cpp)
- *
- *  Created on: Oct 21, 2011
+ *  Created on: Jun 04, 2012
  *      Author: heber
  */
@@ -21,77 +18,11 @@
 #endif
 
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
 #include "CodePatterns/MemDebug.hpp"
 
-#include <boost/program_options.hpp>
-#include <iostream>
-
-#include "Fragmentation/Automation/atexit.hpp"
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "atexit.hpp"
-#include "FragmentScheduler.hpp"
-#include "Jobs/SystemCommandJob.hpp"
-#include "ServerOptions.hpp"
-#include "SignalHandler.hpp"
-
+#include "server_main.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);
+  return server_main(argc, argv);
+}
 
-  ServerOptions ServerOpts;
-
-  // Declare the supported options.
-  boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
-      ("signal", boost::program_options::value< std::vector<size_t> >(), "set signal to catch (can be given multiple times)")
-      ("workerport", boost::program_options::value< unsigned short >(), "listen on this port for connecting workers")
-      ("controllerport", boost::program_options::value< unsigned short >(), "listen on this port for connecting controller")
-  ;
-
-  boost::program_options::variables_map vm;
-  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
-  boost::program_options::notify(vm);
-
-  int status = 0;
-  status = ServerOpts.parseHelp(vm, desc);
-  if (status) return status;
-  status = ServerOpts.parseVerbosity(vm);
-  if (status) return status;
-  status = ServerOpts.parseWorkerPort(vm);
-  if (status) return status;
-  status = ServerOpts.parseControllerPort(vm);
-  if (status) return status;
-  status = ServerOpts.parseSignals(vm);
-  if (status) return status;
-
-  size_t Exitflag = 0;
-  try
-  {
-    boost::asio::io_service io_service;
-    FragmentScheduler Server(io_service, ServerOpts.workerport, ServerOpts.controllerport);
-
-    // catch ctrl-c and shutdown worker properly
-    boost::function<void (int)> shutdownfunction = boost::bind(&FragmentScheduler::shutdown, boost::ref(Server), _1);
-    SignalHandler signalhandler(shutdownfunction, ServerOpts.signals);
-
-    {
-      Info info("io_service");
-      io_service.run();
-    }
-    Exitflag = Server.getExitflag();
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-
-  return Exitflag;
-}
Index: src/controller.cpp
===================================================================
--- src/controller.cpp	(revision fd4d5e9f6169e6fb4f1b3ebf883388e3bcf11569)
+++ src/controller.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -2,5 +2,5 @@
  * Project: MoleCuilder
  * Description: creates and alters molecular systems
- * Copyright (C)  2011 University of Bonn. All rights reserved.
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
  */
@@ -9,8 +9,5 @@
  * \file controller.cpp
  *
- * This file strongly follows the Serialization example from the boost::asio
- * library (see client.cpp)
- *
- *  Created on: Nov 27, 2011
+ *  Created on: Jun 04, 2012
  *      Author: heber
  */
@@ -22,148 +19,11 @@
 #endif
 
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
 #include "CodePatterns/MemDebug.hpp"
 
-#include <boost/assign.hpp>
-#include <boost/program_options.hpp>
-#include <deque>
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <streambuf>
-#include <vector>
-
-#include "CodePatterns/Assert.hpp"
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-
-#include "atexit.hpp"
-#include "FragmentController.hpp"
-#include "ControllerCommandRegistry.hpp"
-#include "ControllerOptions.hpp"
-#include "controller_AddOn.hpp"
-
-/** Print the status of scheduled and done jobs.
- *
- * @param status pair of number of schedule and done jobs
- */
-void printJobStatus(const std::pair<size_t, size_t> &JobStatus)
-{
-  LOG(1, "INFO: #" << JobStatus.first << " are waiting in the queue and #"
-      << JobStatus.second << " jobs are calculated so far.");
-}
-
-inline std::vector<std::string> getListOfCommands(const ControllerCommandRegistry &ControllerCommands)
-{
-  std::vector<std::string> Commands;
-  for (ControllerCommandRegistry::const_iterator iter = ControllerCommands.getBeginIter();
-      iter != ControllerCommands.getEndIter(); ++iter)
-    Commands.push_back(iter->first);
-
-  return Commands;
-}
+#include "controller_main.hpp"
 
 int main(int argc, char* argv[])
 {
-  // from this moment on, we need to be sure to deeinitialize in the correct order
-  // this is handled by the cleanup function
-  atexit(cleanUp);
-
-  size_t Exitflag = 0;
-
-  controller_AddOn *AddOn = getAddOn();
-  ASSERT(AddOn != NULL,
-      "main() - returned AddOn is NULL.");
-
-  ControllerOptions *ControllerInfo = AddOn->allocateControllerInfo();
-  boost::asio::io_service io_service;
-  FragmentController controller(io_service);
-  boost::program_options::variables_map vm;
-
-  // prepare ControllerCommand
-  // note: we need "< ControllerCommand::commands_t >" because parseExecutable(),... return int
-  // in contrast to other functions that return void
-  ControllerCommandRegistry ControllerCommands;
-  boost::function<void (ControllerCommand *)> registrator =
-      (boost::bind(&Registry<ControllerCommand>::registerInstance, boost::ref(ControllerCommands), _1));
-  registrator(new ControllerCommand("checkresults",
-      boost::assign::list_of< ControllerCommand::commands_t >
-        (boost::bind(&FragmentController::checkResults,
-            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
-        (boost::bind(&printJobStatus,
-            boost::bind(&FragmentController::getJobStatus, boost::ref(controller))))
-      ));
-  registrator(new ControllerCommand("removeall",
-      boost::assign::list_of< ControllerCommand::commands_t >
-        (boost::bind(&FragmentController::removeall,
-            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
-      ));
-  registrator(new ControllerCommand("shutdown",
-      boost::assign::list_of< ControllerCommand::commands_t >
-        (boost::bind(&FragmentController::shutdown,
-            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
-      ));
-  AddOn->addSpecificCommands(registrator, controller, *ControllerInfo);
-
-  // Declare the supported options.
-  boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
-      ("server", boost::program_options::value< std::string >(), "connect to server at this address (host:port)")
-      ("command", boost::program_options::value< std::string >(), (std::string("command to send to server: ")+toString(getListOfCommands(ControllerCommands))).c_str())
-  ;
-  AddOn->addSpecificOptions(desc.add_options());
-
-  // parse command line
-  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
-  boost::program_options::notify(vm);
-
-  // set controller information
-  int status = 0;
-  status = ControllerInfo->parseHelp(vm, desc);
-  if (status) return status;
-  status = ControllerInfo->parseVerbosity(vm);
-  if (status) return status;
-  status = ControllerInfo->parseServerPort(vm);
-  if (status) return status;
-  status = ControllerInfo->parseCommand(vm, getListOfCommands(ControllerCommands));
-  if (status) return status;
-
-  // all later parse functions depend on parsed command
-  status = AddOn->addOtherParsings(*ControllerInfo, vm);
-  if (status) return status;
-
-  // parse given ControllerCommand
-  if(!ControllerCommands.isPresentByName(ControllerInfo->command)) {
-    ELOG(1, "Unrecognized command '"+toString(ControllerInfo->command)+"'.");
-    return 255;
-  }
-  const ControllerCommand *commands = ControllerCommands.getByName(ControllerInfo->command);
-  try
-  {
-    // execute each command in the queue synchronously
-    size_t phase = 1;
-    for (ControllerCommand::const_iterator iter = commands->begin();
-       iter != commands->end(); ++iter, ++phase) {
-      (*iter)();
-      {
-        io_service.reset();
-        Info info((std::string("io_service: ")+toString(phase)).c_str());
-        io_service.run();
-      }
-    }
-    Exitflag = controller.getExitflag();
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-  delete AddOn;
-
-  return Exitflag;
+  return controller_main(argc,argv);
 }
 
Index: src/controller_main.cpp
===================================================================
--- src/controller_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/controller_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,170 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * \file controller_main.cpp
+ *
+ * This file strongly follows the Serialization example from the boost::asio
+ * library (see client.cpp)
+ *
+ *  Created on: Nov 27, 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/assign.hpp>
+#include <boost/program_options.hpp>
+#include <deque>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <sstream>
+#include <streambuf>
+#include <vector>
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "atexit.hpp"
+#include "FragmentController.hpp"
+
+#include "ControllerOptions_SystemCommandJob.hpp"
+#include "ControllerCommandRegistry.hpp"
+
+#include "controller_AddOn.hpp"
+
+/** Print the status of scheduled and done jobs.
+ *
+ * @param status pair of number of schedule and done jobs
+ */
+void printJobStatus(const std::pair<size_t, size_t> &JobStatus)
+{
+  LOG(1, "INFO: #" << JobStatus.first << " are waiting in the queue and #"
+      << JobStatus.second << " jobs are calculated so far.");
+}
+
+inline std::vector<std::string> getListOfCommands(const ControllerCommandRegistry &ControllerCommands)
+{
+  std::vector<std::string> Commands;
+  for (ControllerCommandRegistry::const_iterator iter = ControllerCommands.getBeginIter();
+      iter != ControllerCommands.getEndIter(); ++iter)
+    Commands.push_back(iter->first);
+
+  return Commands;
+}
+
+int controller_main(int argc, char* argv[])
+{
+  // from this moment on, we need to be sure to deeinitialize in the correct order
+  // this is handled by the cleanup function
+  atexit(cleanUp);
+
+  size_t Exitflag = 0;
+
+  controller_AddOn *AddOn = getAddOn();
+  ASSERT(AddOn != NULL,
+      "main() - returned AddOn is NULL.");
+
+  ControllerOptions *ControllerInfo = AddOn->allocateControllerInfo();
+  boost::asio::io_service io_service;
+  FragmentController controller(io_service);
+  boost::program_options::variables_map vm;
+
+  // prepare ControllerCommand
+  // note: we need "< ControllerCommand::commands_t >" because parseExecutable(),... return int
+  // in contrast to other functions that return void
+  ControllerCommandRegistry ControllerCommands;
+  boost::function<void (ControllerCommand *)> registrator =
+      (boost::bind(&Registry<ControllerCommand>::registerInstance, boost::ref(ControllerCommands), _1));
+  registrator(new ControllerCommand("checkresults",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::checkResults,
+            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
+        (boost::bind(&printJobStatus,
+            boost::bind(&FragmentController::getJobStatus, boost::ref(controller))))
+      ));
+  registrator(new ControllerCommand("removeall",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::removeall,
+            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
+      ));
+  registrator(new ControllerCommand("shutdown",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::shutdown,
+            boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport)))
+      ));
+  AddOn->addSpecificCommands(registrator, controller, *ControllerInfo);
+
+  // Declare the supported options.
+  boost::program_options::options_description desc("Allowed options");
+  desc.add_options()
+      ("help,h", "produce help message")
+      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
+      ("server", boost::program_options::value< std::string >(), "connect to server at this address (host:port)")
+      ("command", boost::program_options::value< std::string >(), (std::string("command to send to server: ")+toString(getListOfCommands(ControllerCommands))).c_str())
+  ;
+  AddOn->addSpecificOptions(desc.add_options());
+
+  // parse command line
+  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
+  boost::program_options::notify(vm);
+
+  // set controller information
+  int status = 0;
+  status = ControllerInfo->parseHelp(vm, desc);
+  if (status) return status;
+  status = ControllerInfo->parseVerbosity(vm);
+  if (status) return status;
+  status = ControllerInfo->parseServerPort(vm);
+  if (status) return status;
+  status = ControllerInfo->parseCommand(vm, getListOfCommands(ControllerCommands));
+  if (status) return status;
+
+  // all later parse functions depend on parsed command
+  status = AddOn->addOtherParsings(*ControllerInfo, vm);
+  if (status) return status;
+
+  // parse given ControllerCommand
+  if(!ControllerCommands.isPresentByName(ControllerInfo->command)) {
+    ELOG(1, "Unrecognized command '"+toString(ControllerInfo->command)+"'.");
+    return 255;
+  }
+  const ControllerCommand *commands = ControllerCommands.getByName(ControllerInfo->command);
+  try
+  {
+    // execute each command in the queue synchronously
+    size_t phase = 1;
+    for (ControllerCommand::const_iterator iter = commands->begin();
+       iter != commands->end(); ++iter) {
+      (*iter)();
+      {
+        io_service.reset();
+        Info info((std::string("io_service: ")+toString(phase)).c_str());
+        io_service.run();
+      }
+    }
+    Exitflag = controller.getExitflag();
+  }
+  catch (std::exception& e)
+  {
+    std::cerr << e.what() << std::endl;
+  }
+  delete AddOn;
+
+  return Exitflag;
+}
+
Index: src/controller_main.hpp
===================================================================
--- src/controller_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/controller_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,18 @@
+/*
+ * \file controller_main.hpp
+ *
+ *  Created on: Jun 04, 2012
+ *      Author: heber
+ */
+
+#ifndef CONTROLLER_MAIN_HPP_
+#define CONTROLLER_MAIN_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+int controller_main(int argc, char **argv);
+
+#endif /* CONTROLLER_MAIN_HPP_ */
Index: src/poolworker.cpp
===================================================================
--- src/poolworker.cpp	(revision fd4d5e9f6169e6fb4f1b3ebf883388e3bcf11569)
+++ src/poolworker.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -8,7 +8,4 @@
 /*
  * \file poolworker.cpp
- *
- * This file strongly follows the Serialization example from the boost::asio
- * library (see client.cpp)
  *
  *  Created on: Feb 28, 2012
@@ -22,85 +19,12 @@
 #endif
 
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
 #include "CodePatterns/MemDebug.hpp"
 
-#include <iostream>
-#include <boost/program_options.hpp>
-#include <boost/lexical_cast.hpp>
-#include <vector>
-
-#include "Fragmentation/Automation/atexit.hpp"
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Pool/PoolWorker.hpp"
-#include "atexit.hpp"
-#include "Jobs/SystemCommandJob.hpp"
-#include "SignalHandler.hpp"
-#include "WorkerOptions.hpp"
+#include "poolworker_main.hpp"
 
 
 int main(int argc, char* argv[])
 {
-  // from this moment on, we need to be sure to deeinitialize in the correct order
-  // this is handled by the cleanup function
-  atexit(cleanUp);
+  return poolworker_main(argc,argv);
+}
 
-  WorkerOptions WorkerOpts;
-  boost::program_options::variables_map vm;
-
-  // Declare the supported options.
-  boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
-      ("signal", boost::program_options::value< std::vector<size_t> >(), "set signal to catch (can be given multiple times)")
-      ("server", boost::program_options::value< std::string>(), "connect to server at this address (host:port)")
-      ("listen", boost::program_options::value< std::string >(), "listen on this port")
-      ("hostname", boost::program_options::value< std::string>(), "name of host on which this codes runs and which server can resolve")
-  ;
-
-  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
-  boost::program_options::notify(vm);
-
-  int status = 0;
-  if (status) return status;
-  status = WorkerOpts.parseHelp(vm, desc);
-  if (status) return status;
-  status = WorkerOpts.parseVerbosity(vm);
-  if (status) return status;
-  status = WorkerOpts.parseServer(vm);
-  if (status) return status;
-  status = WorkerOpts.parseListenPort(vm);
-  if (status) return status;
-  status = WorkerOpts.parseLocalhost(vm);
-  if (status) return status;
-  status = WorkerOpts.parseSignals(vm);
-  if (status) return status;
-
-  size_t exitflag = 0;
-  try
-  {
-    boost::asio::io_service io_service;
-    PoolWorker client(io_service, WorkerOpts.server, WorkerOpts.serverport, WorkerOpts.hostname, WorkerOpts.listenport);
-
-    // catch ctrl-c and shutdown worker properly
-    boost::function<void (int)> shutdownfunction = boost::bind(&PoolWorker::shutdown, boost::ref(client), _1);
-    SignalHandler signalhandler(shutdownfunction, WorkerOpts.signals);
-
-    // process io requests
-    {
-      Info info("io_service");
-      io_service.run();
-    }
-    exitflag = client.getFlag();
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-
-
-  return exitflag;
-}
Index: src/poolworker_main.cpp
===================================================================
--- src/poolworker_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/poolworker_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,103 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * \file poolworker_main.cpp
+ *
+ * This file strongly follows the Serialization example from the boost::asio
+ * library (see client.cpp)
+ *
+ *  Created on: Feb 28, 2012
+ *      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 <iostream>
+#include <boost/program_options.hpp>
+#include <boost/lexical_cast.hpp>
+#include <vector>
+
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "atexit.hpp"
+#include "Pool/PoolWorker.hpp"
+#include "Jobs/SystemCommandJob.hpp"
+#include "SignalHandler.hpp"
+#include "WorkerOptions.hpp"
+
+int poolworker_main(int argc, char* argv[])
+{
+  // from this moment on, we need to be sure to deeinitialize in the correct order
+  // this is handled by the cleanup function
+  atexit(cleanUp);
+
+  WorkerOptions WorkerOpts;
+  boost::program_options::variables_map vm;
+
+  // Declare the supported options.
+  boost::program_options::options_description desc("Allowed options");
+  desc.add_options()
+      ("help,h", "produce help message")
+      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
+      ("signal", boost::program_options::value< std::vector<size_t> >(), "set signal to catch (can be given multiple times)")
+      ("server", boost::program_options::value< std::string>(), "connect to server at this address (host:port)")
+      ("listen", boost::program_options::value< std::string >(), "listen on this port")
+      ("hostname", boost::program_options::value< std::string>(), "name of host on which this codes runs and which server can resolve")
+  ;
+
+  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
+  boost::program_options::notify(vm);
+
+  int status = 0;
+  status = WorkerOpts.parseHelp(vm, desc);
+  if (status) return status;
+  status = WorkerOpts.parseVerbosity(vm);
+  if (status) return status;
+  status = WorkerOpts.parseServer(vm);
+  if (status) return status;
+  status = WorkerOpts.parseListenPort(vm);
+  if (status) return status;
+  status = WorkerOpts.parseLocalhost(vm);
+  if (status) return status;
+  status = WorkerOpts.parseSignals(vm);
+  if (status) return status;
+
+  size_t exitflag = 0;
+  try
+  {
+    boost::asio::io_service io_service;
+    PoolWorker client(io_service, WorkerOpts.server, WorkerOpts.serverport, WorkerOpts.hostname, WorkerOpts.listenport);
+
+    // catch ctrl-c and shutdown worker properly
+    boost::function<void (int)> shutdownfunction = boost::bind(&PoolWorker::shutdown, boost::ref(client), _1);
+    SignalHandler signalhandler(shutdownfunction, WorkerOpts.signals);
+
+    // process io requests
+    {
+      Info info("io_service");
+      io_service.run();
+    }
+    exitflag = client.getFlag();
+  }
+  catch (std::exception& e)
+  {
+    std::cerr << e.what() << std::endl;
+  }
+
+
+  return exitflag;
+}
Index: src/poolworker_main.hpp
===================================================================
--- src/poolworker_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/poolworker_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,19 @@
+/*
+ * \file poolworker_main.hpp
+ *
+ *  Created on: Jun 04, 2012
+ *      Author: heber
+ */
+
+#ifndef POOLWORKER_MAIN_HPP_
+#define POOLWORKER_MAIN_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+int poolworker_main(int argc, char* argv[]);
+
+#endif /* POOLWORKER_MAIN_HPP_ */
Index: src/server_main.cpp
===================================================================
--- src/server_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/server_main.cpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,95 @@
+/*
+ * 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_main.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/program_options.hpp>
+#include <iostream>
+
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "atexit.hpp"
+#include "FragmentScheduler.hpp"
+#include "Jobs/SystemCommandJob.hpp"
+#include "ServerOptions.hpp"
+#include "SignalHandler.hpp"
+
+int server_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);
+
+  ServerOptions ServerOpts;
+
+  // Declare the supported options.
+  boost::program_options::options_description desc("Allowed options");
+  desc.add_options()
+      ("help,h", "produce help message")
+      ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level")
+      ("signal", boost::program_options::value< std::vector<size_t> >(), "set signal to catch (can be given multiple times)")
+      ("workerport", boost::program_options::value< unsigned short >(), "listen on this port for connecting workers")
+      ("controllerport", boost::program_options::value< unsigned short >(), "listen on this port for connecting controller")
+  ;
+
+  boost::program_options::variables_map vm;
+  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
+  boost::program_options::notify(vm);
+
+  int status = 0;
+  status = ServerOpts.parseHelp(vm, desc);
+  if (status) return status;
+  status = ServerOpts.parseVerbosity(vm);
+  if (status) return status;
+  status = ServerOpts.parseWorkerPort(vm);
+  if (status) return status;
+  status = ServerOpts.parseControllerPort(vm);
+  if (status) return status;
+  status = ServerOpts.parseSignals(vm);
+  if (status) return status;
+
+  size_t Exitflag = 0;
+  try
+  {
+    boost::asio::io_service io_service;
+    FragmentScheduler Server(io_service, ServerOpts.workerport, ServerOpts.controllerport);
+
+    // catch ctrl-c and shutdown worker properly
+    boost::function<void (int)> shutdownfunction = boost::bind(&FragmentScheduler::shutdown, boost::ref(Server), _1);
+    SignalHandler signalhandler(shutdownfunction, ServerOpts.signals);
+
+    {
+      Info info("io_service");
+      io_service.run();
+    }
+    Exitflag = Server.getExitflag();
+  }
+  catch (std::exception& e)
+  {
+    std::cerr << e.what() << std::endl;
+  }
+
+  return Exitflag;
+}
Index: src/server_main.hpp
===================================================================
--- src/server_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
+++ src/server_main.hpp	(revision 7546b0b65f515aa9912563671305e96bb443e945)
@@ -0,0 +1,19 @@
+/*
+ * \file server_main.hpp
+ *
+ *  Created on: Jun 04, 2012
+ *      Author: heber
+ */
+
+#ifndef SERVER_MAIN_HPP_
+#define SERVER_MAIN_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+int server_main(int argc, char* argv[]);
+
+#endif /* SERVER_MAIN_HPP_ */
