Remove unused variables
Get rid of pre python 2.6 hacks (functools)
More unused variables and dead code removed (pyflakes)
Merge pull request #823 from jmaas/master

More code cleanup as result of pyflakes