Refactor, separated system and realm configuration for multi-tenancy improvements.