Improve readability of generated code, and fix #13