Fixed a bug where BlockManager tried to write to a readonly stream
Improved thread safety in BlockManager