Added some additioanl checking before deleting envvars