Refactor codegen methods to rebind methods