Refactor leave, join groups