reference count fixes