Fix NSApp delegate issue