Tag index

Just starting on this, not for merging yet, but feedback welcome.
Perhaps I should look at what this function does, but it's name throws me.