Fix some bugs in cancelation