Completed new state machine. All unit tests pass.