Refactor task system.