Improve getCurrentEnvironment(); other cleanup.