Unify chapter4 with chapter 3.  

Fixes #12