More work on pagination and refactoring.