kd-tree improvements