Refactor main loop and other stuff to allow debug drawing during setup