fix missing file and bad prototype
Fix some memory leaks