Refactored call merging and sorting.