fix quite a few memory leaks