Fixing the pagination and setting up caching of sorts