with some logging for memory leaks