Modified layout of main loop.