Two small changes.

A cosmetic change and reduced the looping to only count to [2^16,2^17]=[65536,131072], since we only keep versions up to one hundred thousand.