I removed lots of sorting assumptions, because we aren't actually making those guarantees. The sorting happened to work out by coincidence prior to my changes in this PR.