Bugfixes and improvement in library and command line scripts.