Add config support, and refactor domain implements.