reorganize compiler code and improve generated code

along the way, improve the JavaScript we output somewhat:
- semicolons in more places
- indentation in more places
- more consistent camelCaseIdentifiers

review/merge by @frankduncan plz