Adds more chap9 code
Cleans up and adds more chapter 9 code