Removed nested RefCounters by introducing a smart pointer.