WIP: Add global lock to OutputStream::write()
Internal OutputStream lock was not enough when writing multiple streams and objects went to a wrong stream. This fix adds a global OutputStream lock as a quick bugfix, until we implement a more systematic solution.
Edited by Marcin Nowak