Split update function into update and render.