Fix race condition when writing to __uniqueTypes