Minor fixes to code generation