Started to implement main loop.