Refactoring (no pun intended) Bunch Kaufman implementation.