Updated to reflect recent change in terra-utils.
Inlining all top-level AD functions; exposing recoverMemory.