Refactor chunk functions and loops of core tasks.