Fixed issues with code generation