Refactor the way domains are handled