Improved the control over ensuring that a permit belongs to the proper
semaphore.