qsort and some changes