Fix sorting and paging