part of #333 memory leaks