FIX Issue #39 Our of order CodeBlocks

Also fixes some other odd errors I've been getting.
And make generated code easier to read.