Factor together some other repeated code.