Fix synchronization issues in merge_sorter.