got chapter 4 working awesome, backported some changes to chapter 3