Rewrite RuleController to get rid of some legacy code
More DRY, add some formatting/line breaks

Remove the unused property "ownRules".
Comment and whitespace fixes

Also fix a tiny code typo

Remove some fixed TODOs
Add recursion detection for @import

And a test
Make @import rules stringify as themselves

(Not as the rules they import)