Sync ch05 source code with ch04.