def _massage_groups_out(appstruct):
    """Opposite of '_massage_groups_in': remove 'groups:' prefix and
    split 'groups' into 'roles' and 'groups'.
    """
    d = appstruct
    groups = [
        g.split("group:")[1]
        for g in d.get("groups", "")
        if g and g.startswith("group:")
    ]
    roles = [r for r in d.get("groups", "") if r and r.startswith("role:")]
    d["groups"] = groups
    d["roles"] = roles
    return d