added root-subdomain option; refactoring