If you rebase your branch onto 4.0.2 you should be able to replace the bulk of this function with the swapWith function I mentioned to you.

partion.swapWith(partitionWork);
partitionWork.kill();