Optimized Org export to single query

Cake was doing 200+ queries to generate the export, this does
everything in 1 query. I also added some indexes to the memberships
table for faster queries.