Group mode initial implementation.
Reorganize group mode handling so that it can be reused in other parts.
Added group mode checking, when adding a new tag.