Preparation for kd tree