Rework domains. Closes #1451