Fixed tree-building algorithm and updated clang toolchain settings