Updated to handle NULL and BLANK values. Replaced var names including 'stats'/'stat' with 'config'/'attr'.