Fix pagination bugs. Improve key range selection.