added some retry and wait logic to ensure that tasks actually get
performed.