refs #738 Untangle a bunch of repeated upsert code