max dist
better style in kdtree.cc
use uniqueptr, bug fixed