added command line tool + bug fixes