Lots of little fixes, plus chapter 9 example.

as above, why this change?