Index: /trunk/FACT++/src/biasctrl.cc
===================================================================
--- /trunk/FACT++/src/biasctrl.cc	(revision 16731)
+++ /trunk/FACT++/src/biasctrl.cc	(revision 16732)
@@ -7,4 +7,5 @@
 #include "Shell.h"
 #include "StateMachineDim.h"
+#include "StateMachineAsio.h"
 #include "ConnectionUSB.h"
 #include "Configuration.h"
@@ -1549,5 +1550,5 @@
 
 template <class T, class S>
-class StateMachineBias : public T, public ba::io_service, public ba::io_service::work
+class StateMachineBias : public StateMachineAsio<T>
 {
     int Wrap(boost::function<void()> f)
@@ -1798,5 +1799,5 @@
         // Now wait until all connection have been closed and
         // all pending handlers have been processed
-        poll();
+        ba::io_service::poll();
 
         if (evt.GetBool())
@@ -1845,11 +1846,4 @@
     int Execute()
     {
-        // Dispatch (execute) at most one handler from the queue. In contrary
-        // to run_one(), it doesn't wait until a handler is available
-        // which can be dispatched, so poll_one() might return with 0
-        // handlers dispatched. The handlers are always dispatched/executed
-        // synchronously, i.e. within the call to poll_one()
-        poll_one();
-
         return fExpertMode && fBias.GetStatus()>=State::kConnected ?
             State::kExpertMode : fBias.GetStatus();
@@ -1858,14 +1852,6 @@
 public:
     StateMachineBias(ostream &out=cout) :
-        T(out, "BIAS_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
-        fBias(*this, *this), fExpertMode(false)
-    {
-        // ba::io_service::work is a kind of keep_alive for the loop.
-        // It prevents the io_service to go to stopped state, which
-        // would prevent any consecutive calls to run()
-        // or poll() to do nothing. reset() could also revoke to the
-        // previous state but this might introduce some overhead of
-        // deletion and creation of threads and more.
-
+        StateMachineAsio<T>(out, "BIAS_CONTROL"), fBias(*this, *this), fExpertMode(false)
+    {
         // State names
         T::AddStateName(State::kDisconnected, "Disconnected",
Index: /trunk/FACT++/src/drivectrl.cc
===================================================================
--- /trunk/FACT++/src/drivectrl.cc	(revision 16731)
+++ /trunk/FACT++/src/drivectrl.cc	(revision 16732)
@@ -1,3 +1,2 @@
-#include <boost/bind.hpp>
 #include <boost/regex.hpp>
 
@@ -11,4 +10,5 @@
 #include "Shell.h"
 #include "StateMachineDim.h"
+#include "StateMachineAsio.h"
 #include "Connection.h"
 #include "LocalControl.h"
@@ -778,5 +778,5 @@
 
 template <class T, class S>
-class StateMachineDrive : public T, public ba::io_service, public ba::io_service::work
+class StateMachineDrive : public StateMachineAsio<T>
 {
 private:
@@ -1179,5 +1179,5 @@
         // Now wait until all connection have been closed and
         // all pending handlers have been processed
-        poll();
+        ba::io_service::poll();
 
         if (evt.GetBool())
@@ -1210,11 +1210,4 @@
     int Execute()
     {
-        // Dispatch (execute) at most one handler from the queue. In contrary
-        // to run_one(), it doesn't wait until a handler is available
-        // which can be dispatched, so poll_one() might return with 0
-        // handlers dispatched. The handlers are always dispatched/executed
-        // synchronously, i.e. within the call to poll_one()
-        poll_one();
-
         /*
         if (T::GetCurrentState()==Drive::State::kLocked)
@@ -1271,6 +1264,6 @@
 public:
     StateMachineDrive(ostream &out=cout) :
-        T(out, "DRIVE_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
-        fDrive(*this, *this), fAutoResume(false), fSunRise(Time().GetNextSunRise())
+        StateMachineAsio<T>(out, "DRIVE_CONTROL"), fDrive(*this, *this),
+        fAutoResume(false), fSunRise(Time().GetNextSunRise())
     {
         // State names
Index: /trunk/FACT++/src/fadctrl.cc
===================================================================
--- /trunk/FACT++/src/fadctrl.cc	(revision 16731)
+++ /trunk/FACT++/src/fadctrl.cc	(revision 16732)
@@ -5,4 +5,5 @@
 #include "Shell.h"
 #include "StateMachineDim.h"
+#include "StateMachineAsio.h"
 #include "Connection.h"
 #include "LocalControl.h"
@@ -544,5 +545,5 @@
 
 template <class T>
-class StateMachineFAD : public T, public EventBuilderWrapper, public ba::io_service, public ba::io_service::work
+class StateMachineFAD : public StateMachineAsio<T>, public EventBuilderWrapper
 {
 private:
@@ -1386,11 +1387,4 @@
     int Execute()
     {
-        // Dispatch (execute) at most one handler from the queue. In contrary
-        // to run_one(), it doesn't wait until a handler is available
-        // which can be dispatched, so poll_one() might return with 0
-        // handlers dispatched. The handlers are always dispatched/executed
-        // synchronously, i.e. within the call to poll_one()
-        poll_one();
-
         // ===== Evaluate connection status =====
 
@@ -1648,5 +1642,6 @@
 public:
     StateMachineFAD(ostream &out=cout) :
-        T(out, "FAD_CONTROL"), EventBuilderWrapper(*static_cast<MessageImp*>(this)), ba::io_service::work(static_cast<ba::io_service&>(*this)),
+        StateMachineAsio<T>(out, "FAD_CONTROL"),
+        EventBuilderWrapper(*static_cast<MessageImp*>(this)),
         fStatus1(40), fStatus2(40), fStatusT(false),
         fDimStartRun("FAD_CONTROL/START_RUN", "X:1;X:1",
@@ -1659,10 +1654,4 @@
                                                   "|thread[bool]:true or false whether the event builder threads are running")
     {
-        // ba::io_service::work is a kind of keep_alive for the loop.
-        // It prevents the io_service to go to stopped state, which
-        // would prevent any consecutive calls to run()
-        // or poll() to do nothing. reset() could also revoke to the
-        // previous state but this might introduce some overhead of
-        // deletion and creation of threads and more.
         ResetConfig();
         SetOutputFormat(FAD::kNone);
@@ -1949,5 +1938,5 @@
         }
 
-        tcp::resolver resolver(get_io_service());
+        tcp::resolver resolver(StateMachineAsio<T>::get_io_service());
 
         boost::system::error_code ec;
Index: /trunk/FACT++/src/ftmctrl.cc
===================================================================
--- /trunk/FACT++/src/ftmctrl.cc	(revision 16731)
+++ /trunk/FACT++/src/ftmctrl.cc	(revision 16732)
@@ -5,4 +5,5 @@
 #include "Shell.h"
 #include "StateMachineDim.h"
+#include "StateMachineAsio.h"
 #include "Connection.h"
 #include "LocalControl.h"
@@ -1397,5 +1398,5 @@
 
 template <class T, class S>
-class StateMachineFTM : public T, public ba::io_service, public ba::io_service::work
+class StateMachineFTM : public StateMachineAsio<T>
 {
     int Wrap(function<void()> f)
@@ -1877,5 +1878,5 @@
         // Now wait until all connection have been closed and
         // all pending handlers have been processed
-        poll();
+        ba::io_service::poll();
 
         if (evt.GetBool())
@@ -1933,11 +1934,4 @@
     int Execute()
     {
-        // Dispatch (execute) at most one handler from the queue. In contrary
-        // to run_one(), it doesn't wait until a handler is available
-        // which can be dispatched, so poll_one() might return with 0
-        // handlers dispatched. The handlers are always dispatched/executed
-        // synchronously, i.e. within the call to poll_one()
-        poll_one();
-
         // If FTM is neither in data taking nor idle,
         // leave configuration state
@@ -2033,15 +2027,6 @@
 public:
     StateMachineFTM(ostream &out=cout) :
-        T(out, "FTM_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
-        fFTM(*this, *this)
-    {
-        // ba::io_service::work is a kind of keep_alive for the loop.
-        // It prevents the io_service to go to stopped state, which
-        // would prevent any consecutive calls to run()
-        // or poll() to do nothing. reset() could also revoke to the
-        // previous state but this might introduce some overhead of
-        // deletion and creation of threads and more.
-
-
+        StateMachineAsio<T>(out, "FTM_CONTROL"), fFTM(*this, *this)
+    {
         // State names
         T::AddStateName(FTM::State::kDisconnected, "Disconnected",
