Fix race condition in team creation