Move generic functions to library.js.