bug fix for task cleanup