Proper error response handling

Fixes #7