Trying to fix a few resource leaks