Chapter 5 source code.