Refactor tag parsing to make better use of underscore functionality