Sorting fixes