Simple finite state machine "template".