fix memory leak
fixed crash
Fixed warnings