This is sufficiently convoluted that I'm fairly confused about what's going on.  I consequently fear that it may be a bad example to use anywhere near a tutorial.  Adding a few more comments might improve the situation somewhat; e.g. for the $(maps) class, a comment like
```
e.g. when name is Host2, only App1 gets set here ...
```
and then, for the $(groups_$(gmaps)) class, one following up with
```
 ... so GrpA, GrpB and GrpC get set here.
```