Refactor code generator