Fix MemoryWrite bug