Optimized some querries as well as paginate on a couple of pages