Moved most of the top level code generation in the compiler file, and lots of other smaller things.
Merge.