Code cleaning, moved statistics to task.