Fix some issues in MiscSorter and optimize