Best regard,
It turns out that I create a tag or a task or a quiz, and it effectively adds them.
But when I delete that tag or that task, in the database it is not deleted, that tag still exists in the database.
And as I am doing some queries to the DB I will always appear those tags, since I would not be eliminating from the DB.
If you just delete a tag in the database, you will need to purge some caches. Why not just using the API functions?