tree building fix
big perfomance changes; sources stuctures