Substantial work on chapter 4. Committing so I don't lose anything.