Locks
Fix tests
Semaphores and simplification