Move tagging code to new subdirectory

Rearranging the tagging code will make it easier to split the code off
to be a separate library.