Correct some bugs