Refactoring of Chunk generation.