Fixed various issues with streaming, including managed memory leak