Improve performance of MergeValues by using IORefs