Fixed memory leaks.