fix bugs and implement some new features