This completes the changes required for #221.

Adjusts for the fact that the old task.is_waiting() test used to return
True for retrying tasks as well as ones in the 'waiting' state. Now we
do direct tests on the state value, so must check for 'retrying' too
where appropriate.