Intermediate function to manage streams.