Factor out message checking.