Fixed the error macros to be threadssafe.