Corrected bugs according to HW7 instructions.