An event based finite state machine library