restructuring and added comments to all the major scripts