Improved error handling (client and server).