Corrected and (superficially) tested semaphores