fix a few memleaks