Added some handling of timeouts.