Tree building fixes