Added better error handling on SSL and HTTP errors (Fixes #1)