Internal data structures are hard, fixed a bug in sort