Improved code and functionality of tray icon