Use the Conditions library instead of open-coded lock hackery