Fix number of potential memleaks