Refactor chunk reader, in separate file