Replace RefCounter with std::shared_ptr if possible