Adding url error handling. Resolves #1 and fixes #2.