Fix race condition on startup