Fix more race conditions