Added Exception catching on main loop.