Fix some error and remove some code