Fix bugs, add file indexing script