Fix sorting and tracking.