various improvements:
- removing some redefinitions of global variables inside functions
- removing commented import of gobject
- replacing unused variables by _ in for loops