Fix more missed qpol refactoring.
Python 3: fix more dict .keys() usage.

Uncovered by 2to3.  Unit tests now pass in Python 3.