Refactored cancel feature in backend, algorithm, and test
Manual merge