Reimplementation of the pagequality support

Change-Id: I108e87f5c686418137c6af2c4816571dacf2ed2c