Added smarter sort to optimize upload & help preventing errors