More additions in attempts to fix the kd-tree