Locally scope `i` in sweepDown and sweepUp

Fixes #127