clean up code and remove quit code from main loop