Fixed a few memory leaks