Cleaned up way SetEnvironmentVariable was being used to avoid possible overwrites.