Properly handle memory management for merge sort implementation.