Fixed the controller authentication procedure and some memory leaks in the rule-factory method.