fix nroots sorting and misc changes

fixes #8296