Improved rule matching and rule preservation