Revert "Refactor tag related code"

This reverts commit 08e5565fd98a54af4688f33081555f90e64d1cd2.