Moved merge functions out of module in to main lib.