Fix some bugs and add new feature