Index: trunk/lib/FlairCore/src/Thread.cpp
===================================================================
--- trunk/lib/FlairCore/src/Thread.cpp	(revision 138)
+++ trunk/lib/FlairCore/src/Thread.cpp	(revision 139)
@@ -78,4 +78,6 @@
 bool Thread::IsSuspended(void) const { return pimpl_->IsSuspended(); }
 
+bool Thread::IsRunning(void) const { return pimpl_->isRunning; }
+
 void Thread::Resume(void) { pimpl_->Resume(); }
 
Index: trunk/lib/FlairCore/src/Thread.h
===================================================================
--- trunk/lib/FlairCore/src/Thread.h	(revision 138)
+++ trunk/lib/FlairCore/src/Thread.h	(revision 139)
@@ -176,4 +176,12 @@
   */
   bool IsSuspended(void) const;
+  
+  /*!
+  * \brief Is the thread running?
+  *
+  * \return true if thread is running (call to Start). A suspended thread is running.
+  *
+  */
+  bool IsRunning(void) const;
 
   /*!
Index: trunk/lib/FlairCore/src/unexported/Thread_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/Thread_impl.h	(revision 138)
+++ trunk/lib/FlairCore/src/unexported/Thread_impl.h	(revision 139)
@@ -49,4 +49,5 @@
   int WaitUpdate(const flair::core::IODevice *device);
   bool period_set;
+   bool isRunning;
 
 private:
@@ -58,5 +59,4 @@
   uint64_t cpt;
   flair::core::Time period;
-  bool isRunning;
   bool tobestopped;
   bool is_suspended;
Index: trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp	(revision 138)
+++ trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp	(revision 139)
@@ -215,28 +215,27 @@
       }
     } else {//!UseXbee()
-			if(connection->connected()==vrpn_true && !isConnected) {
-				isConnected=true;
-				Printf("VRPN connected\n");
-			}
-			if(connection->connected()==vrpn_false && isConnected) {
-				isConnected=false;
-				Printf("VRPN disconnected\n");
-			}
-			
-			//timeout in mainloop is not well handled if not connected...
-			if(isConnected) {
-				//this is when trackables callbacks are called:
-				if(connection->mainloop(&timeout)!=0) {
-					self->Warn("connection dropped\n");
-				}
-				//printf("%lld\n",GetTime()/(1000*1000));
-				mutex->GetMutex();
-				for (unsigned int i = 0; i < trackables.size(); i++)
-					trackables.at(i)->mainloop();
-				mutex->ReleaseMutex();
-			} else {
-				connection->mainloop();
-				self->SleepMS(10);
-			}
+        if(connection->connected()==vrpn_true && !isConnected) {
+            isConnected=true;
+            Printf("VRPN connected\n");
+        }
+        if(connection->connected()==vrpn_false && isConnected) {
+            isConnected=false;
+            Printf("VRPN disconnected\n");
+        }
+        //timeout in mainloop is not well handled if not connected...
+        if(isConnected) {
+            //this is when trackables callbacks are called:
+            if(connection->mainloop(&timeout)!=0) {
+                self->Warn("connection dropped\n");
+            }
+            //printf("%lld\n",GetTime()/(1000*1000));
+            mutex->GetMutex();
+            for (unsigned int i = 0; i < trackables.size(); i++)
+                trackables.at(i)->mainloop();
+            mutex->ReleaseMutex();
+        } else {
+            connection->mainloop();
+            self->SleepMS(10);
+        }
     }
   }
Index: trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp	(revision 138)
+++ trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp	(revision 139)
@@ -56,14 +56,4 @@
   }
 
-  if (parent->UseXbee()) {
-    parent->pimpl_->AddTrackable(this, id);
-    tracker = NULL;
-  } else {
-    parent->pimpl_->AddTrackable(self);
-    tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection);
-    tracker->register_change_handler(this, handle_pos);
-    tracker->shutup = true;
-  }
-
   // state
   cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1);
@@ -91,4 +81,18 @@
   z_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "z", -2, 0);
   z_plot->AddCurve(output->Element(6));
+  
+  if(parent->IsRunning()) {
+    self->Warn("adding VrpnObject on running VrpnClient can crash\n");
+  }
+  
+  if (parent->UseXbee()) {
+    tracker = NULL;
+    parent->pimpl_->AddTrackable(this, id);
+  } else {
+    tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection);
+    tracker->register_change_handler(this, handle_pos);
+    tracker->shutup = true;
+    parent->pimpl_->AddTrackable(self);
+  }
 }
 
@@ -106,5 +110,7 @@
 }
 
-void VrpnObject_impl::mainloop(void) { tracker->mainloop(); }
+void VrpnObject_impl::mainloop(void) { 
+     tracker->mainloop();
+}
 
 bool VrpnObject_impl::IsTracked(unsigned int timeout_ms) {
