Chapter-4 code updates for final drafts(WIP).