Fix replaceRule methods

Make them synchronous, fix cache management bugs, and make them take
rules, not file names.

Rename RuleController.parse to RuleController.parseFile