refactor KDBTree code so things are public/private in a reasonable way