make the clean_environment a bit safer