Fixed reference counting

The Release method from the base class was not virtual, so there would
be memory leaks
Fixed how the reference counter is used
Added Release methods for all derived objects