Refactor pagination - to be done more at some point.