Updated code to go up to parts 4.6 of the book.