Remove unused variables and restore cancel trigger