Added garbage collection of derived objects.
Self-review