Fix memory leak in tags