initial code for multi-tenant, some mailbox fixes