Add more reference counting checks
Change ref counting