Added some sort utils, other fixes.