the final version

the final version of the code
advanced kd-trees scheme implemented