Some cleaning and better error message