Simplify, document code preventing race conditions