Reloading the groups outside of the send cycle is safer.
Make clear that the groups variable will have been assigned to after successful parsing.
Drop the pretence that groups is a non-global var.

Also change the free routine from a recursive to an iterative algorithm (thus
preventing a possible-but-unlikely crash where someone creates so many groups
that the free routine runs of stack space).