Refactored (not finished) the logging rules.