remove unused query import, pep8 changes, code improvements

replaced statements like
x = x + 1
by
x += 1

Change-Id: I17f981bd991eafa7d6ab24be7776f5788e02398b
Merge "remove unused query import, pep8 changes, code improvements"