Refactored group management (#745)