Bug fixes and library-ification.