Some fixes for changing environments.