Corrected event-handling. Events will now be handled inside the gameloop.