Correctly merge rules into a