Minor cleanups of the generated code

First attempt at making the generated code smaller and faster. If this seems promising, I have a few more things on my list to try out (mostly around simplifying the mapping individual values to/from JSON).