[#2422] Improve PQM branch.

Problem
=======

PQM fails with strange errors.

Change
======

I really don't know what I am doing... I tried to fix it... we will see if it works in future merges.


How to test
==========

reviewers: @alibotean 

this is just to let you know about the changes.