Fix tag-related bugs