Updated authentication code. Correctly locks/semaphores sign usage