Fix #95: Add finite state machine
Fix imports once and for all