fix #325; trim and safely truncate tag names