cleaned up the tag-generation code and
tweaked a few things here and there