Fix data races in #270