Improviments in the CleanWD function