Refactored task definition to be more declarative and add support for chunks