This adds a deadline to all algorithms which lets one bail in a fixed amount of time to avoid pathological cases.