Chapter 5 rewrite (#286)

I've removed a lot of detail that simply wasn't necessary because the material was already covered in chapters 3 and 4.

I also went through the source code attached to the original tutorial and made a lot of style changes to make it look like example code elsewhere in the book.

It's quite a big diff in the end. Hopefully I've made things clearer and less obviously transplanted.