Fix Linux build
Fix memory leaks