Fix recognizing orphaned tasks on agent announce

NULL values cannot be checked for in sqlalchemy with "is None", it needs
to be "== None".
Remove unused variable "updated"
Typo fix in log string
Fix setting state of task for retrying

The previous strategy used was wrong and would silently fail.
Log when a task is being retried.
Merge pull request #171 from guidow/fix_restarting_tasks

Fix restarting tasks