Fix race condition for engine