cleanup some global variables in main.c

- drop unused
- move to according groups
- make local if possible