Separated out some functions.