fixed handling of pivot to make QS work. Works on all tests so far