change code style, fix some bug