Cleans up cancel and pulse logic and fixes bugs.