Fix many bugs in Chapter 04.

Resolved #18, #20 .
Merge pull request #35 from lijunle/fix-chapter-04

Fix many bugs in Chapter 04.