Port some features from Semaphore Recovery.