Fixed bugs in index-recreation script.