Small fixes.
Rewriten as class Sweeper with code improvements and optimizations.