I pushed a few more commits (an updated patch is attached) which fix some edge cases with ephemeral groups and simplify some functions. Daniel