'undefined variable' and 'redefined' bugs fixed

line 539: res is already declared
line 351: reference to unknown global variable term
line 352: reference to unknown global variable term
line 356: reference to unknown global variable term
line 361: reference to unknown global variable term
line 421: reference to unknown global variable res
line 422: reference to unknown global variable res
line 426: reference to unknown global variable res
line 615: reference to unknown global variable parseCharacterClassEscape