Added comments explaining what is going on.