Updated finite-state machine implementation.