Add timeout, factoring out common code from sleep.
4 files changed