Another attempt at fixing the locks on Linux/Mac