Removed race condition in stream initialisation

Fixes #34