Moved common functions for the binaries to the library.