Bug fixes for the environment script.