It is still not very readable. Please see this post for explanations on how to correctly quote text in this forum. It has “please read this first” in the subject for a reason.
That is not correct. It does work with dynamic groups, but then you must not use averaging (i.e. nrepeat must be 1, not 2) as that would result in bogus averages if the group members change.
That is for you to figure out. But it doesn’t look like you are doing it correctly. I don’t see you deleting a group. If you don’t delete it first, the group command will just add members to the existing group, but not delete. This is documented behavior, of course.