Fixed various bugs in MemoryBlockStream