Fixed a bug where deletion of a task crashed the program.