Fix some bugs in HW4