Fix issues related to part2.
Simplify part 2 task allocation logic