Refactoring of handling of duration.