Extracted struct related func
Added index dir back
Moved ensureDir to util and added index dir to ensureDir
Started changing the index, still WIP