Further refactoring of the rule AI