Added main loop.