Fix compiler warning
Fix memory leaks