Improve Focus on Main Window and Log Exception