Fixed issues in end-of-connection detection and added basic "handling" of stream errors. (They can't really be handled, but at least the user can be informed.)