partially refactored ADSafe into 'encapsulator'