Reimplement reference counted ptr