Refactor the code that sets the window title. Catch tag-events and use title metadata for the window title.