Unassign all group on unit switching, #2535

#2535 
Can you refactor unassigning part into its own method? Up to you where you wanna place it.