better tag handling and tests