reference counting bug fix