fixed some bugs in builder code generation