Fix removing from tree
Fix leaking global