Merge pull request #31 from pezy/master

Finished Chapter 6.
refactor
Merge pull request #34 from pezy/master

fixed some bugs