QSV: big WIP and minor cleanup
For all I know this will help.