I find the _aggregateMembersDocuments and _aggregateMembershipsDocuments functions a bit confusing, and would like to see some additional clarification in the code. For example, indicating that the resourceId will be parts of the principalIds array would be helpful, a better name than principalIds might help as well.