Moved some common consolidation code to a utility class.