Add reference counting around the thread state hash table.