Prevent interleaving of output and error streams.

Ideally this would be handled in the cl