fix bugs around environment variable overrides.