Fix various problems with webstreams code. Add recovery from error/close.