Be a bit smarter about error messages