Added code for chapters 2, 4, 7 and 9