Fix some bugs in Chapter 6, 7, 8