Fix race condition on build