In handle_envchange, actually save the new environment correctly.