fixed broken tree code
solved a few more problems in my spare time today