Fixed database: mutex to semaphore