Fixed bugs near end of part 4