remake - some unification of formula generator. with kdtree makes figures. needed debug abd debug