Rewriting code for KdTree to use new way of splitting and use the Tri struct.