Fix bug in NotifySemaphore