Clean up the tree code.