Generated main method refactor some stuff.
Fixup more of the code generation