Proper error handling in client

Fixes issue #26