Make sweeper code thread-safe