pep8 and pyflakes applied

I didn't do anything with line length yet.
NOTE FOR MYSELF: this loop is used for collection.ensure_index, as there is no index in resultdb. it's useless.