Added from Exercise 1.35 to 1.37 (incomplete) and refactored.