Fixing a bug with releaseDetach that never detaches the semaphore

releaseDetach was always adding to number of attached permits, when it
should be decrementing it. The permits delta required for attachDetach
is always the negated number of permits that you're releasing on the
semaphore.