added finite state machine for the debug ui and hooked it up to the ui.