Fixed issues in code generator