Fix a few resource leaks.