Refactoring domain layer. #41

Please review #41, and merge to master branch.