Updated main() with a few comments to illustrate high level flow.