Fixed some bugs in lab8 and lab12.