Fixed minor bug in sharedmem writing