Fix race in StateMachine thread

The thread was started too soon, before the state machine was
initialized. Easy fix: start the thread later. Thanks, valgrind.