Parameterized TAG and VAL
Check VAL for validity
Added command-line params
Added usage
Added debug info