Improved sorting of ids (done numerically if possible) and altered group limit