Fix existing element removal

Fixes element removal from both existing nodes and root nodes. The former is a bug in the implementation. For the later case there is a fair amount of memory overhead introduced due to root objects not being possible to reclaim.
Merge pull request #452 from kpdecker/removal-fixes

Fix existing element removal