Refactor implementation.
Verify that chunkBy is usable with pure @safe nothrow