Remove make_env_N functions and fix a few bugs
Fix bug in code generation for min and max