Some cleanup regarding stream closing.
Merge pull request #754 from hneuer/streams

Some cleanup regarding stream closing.