Fix group hierarchy to prevent errors

- group hierarchy breaks when there are no groups,
i.e. when starting a new application