Moved SortBuffer into its own class.