Fixed a bug in the task context saving code.