Swtitch to stdlib mutex and cond vars