Rewrites of the environment command so we get better documentation and structure.
Removed unused code.
Added more documentation.