fixed two memory-leak regressions introduced by recent changes to tree code