Started implementing groups and did some refactoring