Added printing of statistics, workflow with log updated, refactoring.