Return after emitting error and avoid sharing streams

Fixes #6 and #7.