Patch by hardon. Properly handle 0 timeouts. Fixes bug 857.