Improved detection of starting/ending times.