Refactoring chunk logic.