Fix some errors and add a new feature