plugged a few memory leaks