Modifications for correct use of timeout and slightly improved error/debug output...