fix bugs with smudge and clean scripts