Improved implementation of RefCountPtr