Made the global environment a singleton and added some functions for
accessing environments.