Improve clean_environment namespace