Added main loop.
Simplified main loop.
Fixed line lengths.