Refactor RefCounterObject and generics fun