Remove some duplicate code.