removed unused assignments and imports

It was time to run``pyflakes`` again. And as you can see in the diff, it was worth it. In some cases I wasn't sure if removing the unused assignment might introduce a bug or if some code was missing which uses the unused name. In these cases I added a comment above the affected line(s). Comment on them please and tell me how these issues should be resolved.