Fork from Thomas's EDTS without changes.