Implement some new features and fix some bugs