Changes to fix the bugs