[pyqr] Refactor.