Fix some possible memleaks.