Cosmetic: factor out common code.