Fix some more race conditions Upstream-commit: 51b188c5102e86ad453c933077bcaf9594070c28 Component: engine