Rewrite mctag

Guillermo already reviewed this once in another branch (I think I should have just merged this into master before) but in any event I thought it would be a good chance to get familiar with PR review.