Main loop and events added