Minor changes in sorting