Cleanup and fixing to allow for use in the common library.