Fixed issues with tree builder