got statemachine done, mostly tested