improve pagination, fix some performance issues and add sorting to detailed search