Fixed potential (but unlikely) memory leaks related to logging