Finished chapter 24; added state restoration