Fix warnings
Fix memory leaks