Added paging and sorting to the backend. Refactored queries and header paging info into a helper class.