I think this is a fix for the unbounded results map that you mentioned earlier. Can we split this fix into it its own review? Also s/cleanupTask/terminalState/