Moved retry timer to its own class, and removed duplicate code in event handling.