Revert "Fixing a bug with releaseDetach that never detaches the semaphore"

This reverts commit c3ed206321e5e50d7a26c49dba2985a95faf60b8.