Some code preparation for task handling