Fixing bug in LocalTasksApi causing stack overflow