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.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>