Logging cleanup and weak references for callbacks.