Major refactorings; introduce type aliases for domain.