Adds error handling for urllib2 and API errors

Fixes issue #9 and #11