Fix nearest-neighbor search, add k-nearest-neighbor search, fixes #11