Added time constraints and bailout feature.