Improved stream handling.