Framework for a finite state machine