[support.cftree] Fixed bugs with distance calculation