Fix bugs in turnEnd