Run static analyzer.
Removed unused window.
Fixed mem leak.