Writing multi-tenant systems