Streams were not cleaned up correctly