fixed leaked delivery wrappers when using events
added getHostname to Connection interface
fixed error/end of stream handling