removed the parent_group_id field, small fixes
refactoring, cleanup, tests added