added a cleaning function to the layerMerger