Reduce code duplication a bit.