Fix bug in team handling