fixed memory leak
Fixed compilation warnings