Fixing sempahore overcount problem