Add merging rules before saving to file