Refactor groups

Cleaned up implementation