Fixed bug where environment file would not be replaced on save.

Also fixed (potential) bug where certain required environment variables
would not be initialized on environment load.