Added StateMachine class; remove comments to internal methods