fixed a few memory leaks