Revert "introduce StateMachine class"

This reverts commit 87e72b081d9e86ebf465ef35b88c0714dc03ea57.
Revert "use StateMachine"

This reverts commit d35fcdb60153381af961436260d5084c31d0ed68.