Simplified main loop.