Improve getCurrentEnvironment().