add NthTupleFromBag, VisitFrequency; update MergeTuples