Greatly improved CURL error handling