toggle team switch, code cleanup

Toggle switch when adding players. Remove redundant code and create
functions for modularity.