added ref_count sanity check