Bugfixes for environment variable logic.