Fixed various tag issues: Duplicate tags being created, old tags not being removed etc.