Fix a index format bug.
Fix bugs for empty directories and merge.