A few more functions on environments.
Refactoring.