Clearing all data structures, and inserting files
switching indices