Change check_ref_format() to take a flags argument