Minor changes to buildTree