fixed calculation of duration
Merge branch 'master' into fix-tp