Deadlock in RPC function setTeam and small changes