Updates to Chapter 5 code