fixing up kd tree and fixed ring buffer memory leak