Add debugging for rules.
Remove dead code.