[2.0] Code clean up

This mostly fixes missing or inappropriate scopes of loop variables in
for-loops. This means all loop variables, unless still needed after a
loop body, should now be declared using the `let' keyword as per the gjs
style guide.

The diffstat makes this look way more invasive than it is which is mostly due to the fact that this also removes a lot of trailing whitespaces.