Extract knn errors, and simplify sortedtargetcollection