Eliminate some circular references potentially preventing garbage collection by avoiding passing self as a lambda parameter.
Add some deallocation debug code.