Better memory handling for streaming