Fix a bunch of curl problems and improve error messages.