Complete chapter 1, address bugs (fixes #51)