Updated lib and command line application

Please merge.