Optimize streams and garbage collection