added extensive comments to source