Fix allocation errors in external sort