Race condition bugfix