Add comments to the main functions

Just added some comments explaining things