Factor out utility functions.