Rearrange the timeout logic to be a little more efficient

Also beef up the comments a bit