moved clear_ref_flags and count_ref_flags from cg_list_global_T to cg_list_T