Replace tags at config time instead of every write

This fixes:
    UnboundLocalError: local variable 'tags' referenced before assignment

Python assumes that a variable is local as soon as you assign it
a new value.