Clean up error handling in client code, and fix some URI issues in server code.