Fixed the bugs. Chapter 4 seems to be working.