Fix some bugs before I complete the code.