tidy some more error messages and SQL