Sorting fixes and other things