Fix passing tagNames into query and externalize getTagNames.