Adjust calculations and add comments