refactor ninja main() into a struct with methods

This removes the ugly Globals struct, and the ResetState() hack.
This also eliminates the only goto!