Various fixes to the DB indexing script.