Changed main loop update and render logic