Fix some memleaks found by coverity