Fix some bugs, and remove indexes of removed files