---fixed barriers to fix race conditions