Added exercise 1.40-1.43 and refactoring.