improvements and changes to match the book text