pep8 and pyflakes applied

I didn't do anything with line length yet.
ok, this certainly makes sense in the sample_handler. Let me know when you've checked the other bits and I'll rebase and send a new pull request. I've also made all lines 99 chars or less in my fork, do you have any thoughts about that? Some people really want this, others want to have longer lines.