Remove some code repetition.