Get rid of some duplicate code.