fixing bugs in code generator