Fix various leaks found by coverity