make sweeper code thread-safe