Converted remaining rules to the new rewriting system.
Removed legacy code and made defrule simpler.