Chunk generator. Refactoring.