Moved most code into common rule classes.