Refactoring tag service and APIs