fixed a few deviations from the book