Many bug fix, test fix and use native sort for Q