dynamically choose number of libraries.
printlog: should print both to stdout and to log file.