Move matching/detection logic to modules.