Added comments to code where necessary