fix code generator/bugs