restore script fixes from Craig Bryant