StateMachine update 1

final work in state machine code, minor simulation problems