Fix race condition in session pool creation
Fix bug in stream iteration