Make qs randmat and thresh ammenable to the optimization pass.