Some changes to the task system, fixed a NullPointerException