Reorganize type inference and codegen source code