Added debugging to tree builder