fix bug in unifying sets and references