Refactoring for multi-tenant compatibility