First half of Exercise 2.91 done; of course, I haven't tested it yet...