Fixed reading duration + some code refactoring.