Stop team menu from being closed prematurely (fixes #225)
Refactor some team code