Finished pagination improvements

Finally got the pagination to work properly with previous and next
buttons.