Refactor in preparation for showing alerts grouped by reason