Fix a few bugs with env vars