Clean up various memory leaks.