Refactor to allow for recursive group definitions, and implement simple
and complex groups