Added more sophisticated pausing.