Improving kd-tree performance