REL-2074: Fixed possible NPE in QPT and cleaned up code.

Good points. Done.