Fix sorting and other things