Pull out common functions into a library file.