Fix leaks in tree trimmer.