Further attempt to fix race condition causing duplicate writes.