adding command line tool, some minor cleanup