Fix some bugs