randomize work to reduce lock contention while indexing; fix a bug where we skipped the final rebuild batch