Replace RefCounter with a smart pointer