Fix implementation of chunking