fix some bugs and clean