You asked about the syntactic function of the gerunds in various examples. As you will see below, in general they are functioning as head of a clause (as a verb) or noun phrase (as a gerundial noun). 'Head' is a function, it is the most important word in a clause or phrase.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.