Added the New Menu item and window close call back event. realigend some of the existing code for readability