fix some memleaks