kdtree refactoring