Fix setup_env some more

There are a few broken things in setup_env that need fixing. This is a catchall for those.