Refactoring of comprehend.mutable.
Much improved semaphore implementation. No longer block indefinitely if IO is slow.