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.

Apologies for the multiple commits - line ending issues with Windblows vs. Unix. You're dealing with a GitHub n00b here...