Add better error handling for certain requests. Fixes #7.