Adding semaphore and reactor management