Codegen ported and seems to be working!