Using elasped time instead of sleep to check the timeout.
Minor refactor.

SS-3521