add some command line tool for debug purpose, and bug fix