Beginning chapter 4 - some fixes to code in previous chapters