Code cleanup

Fixes few code errors found by pyflakes.