The simple state machine implementation.