Added tools to track down memory leaks, and plugged several leaks esp. related to pd_crypto instances not being properly cleaned up.