Slight optimization in handleEvents
Solved some warnings