Moved common code in a library.