more debug info in tw and better sorting for CS