Changed binary semaphores to native mutex types for performance.