Slightly better pagination logic.