Improved handling of streams