Separated out utility functions.