fixed short running background task bug but also discovered very subtle race condition.