Some more sorting, not sure I like it, but seems to work for now.