Fix and simplify threading macros