Fix bugs in removing attached tags