stream handling cleanup