Finite state machine library