Use main() function, fixed governing loop so it exits properly on 'quit'
Tweaks