Rewrote code for time outs and errors.  Added new tests.