Fix some bugs in CS