State machine library