Fix multiple bugs in chapter 18-20