Refactor some rules to make better use of captures