Better client side error handling. Fixes #1