fix some bugs and implement some new features