fix some bugs and code style

fix some bugs and code style