Fix poor batching with mac/ancient drivers. Also, some minor tweaks to sorting algorithm.