Tag index

Just starting on this, not for merging yet, but feedback welcome.
OK, but the system will be OK if the database name had changed by the time line 359 executes?