Cleaning and error fixing